Hi!
Disclaimer: I haven't tested if this is already fixed or not, but lately I've been involved in cleaning up incorrect url rewrites from 2 shops where the url_path for product entities was filled in and both of those shops were migrations from Magento 1 where this tool was used, but I wasn't directly involved with the migration itself. I have the suspicion that this tool transferred those attributes over. Anyway, if I'm mistaken, feel free to close this ticket.
So: when you create a product in Magento 2 using the backend, or using the API, it will never fill in the attribute url_path. Feel free to double check this, because last time I did it was already a couple of months ago.
But when this attribute is filled in, it is actually being used by Magento's Url Rewrite mechanism and that can lead to significant problems with those url rewrites.
In our case, deleting all those url_path attributes and then re-generating the url rewrites using some third party tool fixed our issues.
So, if this tool transfers that url_path attribute over for product entities, you might need to change that, so it doesn't get transferred over.
Be aware, for categories the url_path attribute needs to be transferred over, because that one is very important to exist in Magento 2
Thanks!
Thank you @hostep for the extended explanation of the issue. I will check it
Yes, sounds like the same problem indeed.
Hello hostep,
I have been hounding this issue for quite some time. The major issue for me has been that url_path is not updated or regenerated when the url_key field is updated or generated. I don't know if they're related fields or if there is a relationship between the two fields. I can confirm on 2.2.5 that this issue persists. Whatever url_path attributes came over from M1 persist and no amount of updating the url_key field will fix the url rewrite table. If you manually delete all rewrites for a given entity_id and resave the product, with an updated url key (which triggers the now inaccessible core url rewrites regeneration logic) the url rewrite will still be wrong.
As you pointed out, the issue is that url_path, if it exists, is still populated with the old key. It seems like this is a perfect storm between the url_key/url_path issue and needing to go to a third party to expose logic to regenerate url_rewrites which was exposed via the index in Magento 1.
@Loop-Ben: In my testing, I found out that the url_path attribute is always empty in Magento 2 if you create products manually over there. In my opinion the attribute should be removed entirely from Magento 2's database, I don't know why it still exists if it isn't being used if you use M2 features out of the box.
You are right by indicating that the url_path gets populated when migrating from M1 to M2. And that is a problem that needs to be solved in this module. I don't think it has been handled yet @victor-v-rad?
The best way to solve it on your instance is to make all url_path attributes empty in your M2 shop. That should solve most problems.
And indeed, regenerating url rewrites is no longer a core feature of M2 unfortunately. I've been complaining about that for a while now and have seen no movement yet in that direction. I hope one day it will be added again.
@victor-v-rad: closed because it's fixed, or closed because it's a duplicate of https://github.com/magento/data-migration-tool/issues/462 ?
Yes because of duplicate. But maybe it is better to have it open until the fix implemented
@hostep Just had the exact same problem!
@MageSuper: damn is this still not fixed? This is causing countless of url rewrite issues in Magento 2.
@victor-v-rad: any idea why this hasn't been looked at yet? It's probably 15 minutes of work for you to make sure the url_path for product entities gets imported as an empty value in Magento 2, and to not take over the value from Magento 1, it's this simple.
I haven't used this tool in a couple of years, otherwise I would have send in a PR already to have this fixed.
@hostep sorry it's taken so long to fix it. Please test it on the latest 2.3-develop branch or
b5ad54f
Thanks @victor-v-rad !
Looks good at first sight.
Unfortunately we no longer use this tool for migrating M1 to M2 databases, we have our own scripts for that. So I will not be able to test it I'm afraid.
Thanks again!
Most helpful comment
@MageSuper: damn is this still not fixed? This is causing countless of url rewrite issues in Magento 2.
@victor-v-rad: any idea why this hasn't been looked at yet? It's probably 15 minutes of work for you to make sure the
url_pathfor product entities gets imported as an empty value in Magento 2, and to not take over the value from Magento 1, it's this simple.I haven't used this tool in a couple of years, otherwise I would have send in a PR already to have this fixed.