magento / data-migration-tool

Magento Data Migration Tool
https://devdocs.magento.com/guides/v2.3/migration/bk-migration-guide.html
Open Software License 3.0
335 stars 200 forks source link

Duplicate URL rewrites #606

Open csdougliss opened 5 years ago

csdougliss commented 5 years ago

I'm having an issue with custom url rewrites. The problem I have is that - we have a number of products that exist in Magento back end which are no longer visible on the front end. We have put custom url rewrites for that product to another category, so that the link is now following properly by google or people who have saved links or old emails. Data migration tool thinks these are duplicates.

Another example is that we have a product with a url key of cordless-vacuum-cleaner. We don't want to use the product page for now, so we have put a url redirect from cordless-vacuum-cleaner to some-cms-page (a CMS page).

But when converting the db from m1 to db, we get duplicate URL rewrite issue:

Request path: cordless-vacuum-cleaner Store ID: 31 Target path: some-cms-page
Request path: cordless-vacuum-cleaner Store ID: 31 Target path: catalog/product/view/id/11238

What is the solution here?

I have used the code for https://github.com/magento/data-migration-tool/issues/77 here in the past, which gets past this issue, but then none of my custom url redirects work any more.

Preconditions

  1. Magento 1.14.3.10
  2. Magento 2.2.6
  3. PHP 7.1.23
  4. MySQL 5.7.24

Steps to reproduce

  1. Have a magento product with a url key of s7-duet-master-steam-cleaner
  2. Put in a custom URL rewrite for s7-duet-master-steam-cleaner that re-directs to another category
  3. Run data migration tool conversion
  4. Stops running on 'There are duplicates in URL rewrites'

Expected result

  1. There isn't any duplicates

Actual result

[2018-11-06 08:53:22][ERROR]: There are duplicates in URL rewrites:
Request path: s7-duet-master-steam-cleaner Store ID: 3 Target path: steam-cleaners
Request path: s7-duet-master-steam-cleaner Store ID: 3 Target path: catalog/product/view/id/2668
victor-v-rad commented 5 years ago

Hi @craigcarnell

If you try to do a custom URL rewrite in M2 like you described, you will get an error 'Request Path for Specified Store already exists.' Because you cannot have two same Request Path for one store. But in M1 you can, because you have Duplicate URL Key Priority option in M1. And if you delete your custom URL rewrite 's7-duet-master-steam-cleaner' and open this url key 's7-duet-master-steam-cleaner' on the frontend then M1 will fallback and open the product. In M2 functionality of fallback does not exist and it just do not allow you to create duplicates.

But what I see wrong is the tool hardcoded this priority but should take it from the Duplicate URL Key Priority option. If you need a hotfix for priority, open \Migration\Step\UrlRewrite\Version11410to2000 and change 'priority' => "trim('?')" for collectCategoryRewrites, collectCmsPageRewrites, collectRedirects methods Internal ticket to fix MAGETWO-96173 hardcoded priority

csdougliss commented 5 years ago

@victor-v-rad Will try this tomorrow morning. Will this mean however if it takes the priority for the re-direct (which is what I want), the product will no longer have a url key?

victor-v-rad commented 5 years ago

@craigcarnell if you use 1 in your config.xml, you will see something like this during migration

[mode: data][stage: data migration][step: Url Rewrite Step]: Duplicate resolved. Request path was: s7-duet-master-steam-cleaner Target path was: steam-cleaners Store ID: 1 New request path: s7-duet-master-steam-cleaner-fd1ac9686e0209b28eab523330a09650

with hash in the end of url.