URL key for specified store already exists.

After migrating products, we noticed that URL rewrites were not working for most products, for example we’re getting stuff like this:
In order to recreate the re-write table, we switched to a temporary root category then back again in Stores -> All Stores
When switching back to the correct root (and thereby regenerating rewrites) we receive the following:
URL key for specified store already exists
So we tried running php -f bin/ubdatamigration fixduplicateurl which found/fixed one dup in catalog_category_entity_varchar and no dups in products.   After reindex and cache flush, we are still getting URL key errors when trying to rebuild rewrites.

Some additional info:

  1. DO NOT have this issue using magento’s built-in data migration tool on the same data.   re-writes work and no errors trying to recreate them
  2. This is a 100% fresh magento install before data migration.
  3. We also cannot edit URL keys in ANY category — error is “The value specified in the URL Key field would generate a URL that already exists.”

Thanks in advance for any assistance, we are really hoping to be able to use this great module.

  1. Profile photo of fast.servfast.serv 10.00 $tone October 3, 2018
    OK after alot of debugging, it turns out the issue is that one of the products has the same URL key as a category. Updating the offending product key solved the issue, but finding WHICH product was very difficult with a large inventory.We had to insert some debug code in magento/module-url-rewrite/Model/Storage/DbStorage.php to dump the SQL error since magento does not log this error at all. There is one gigantic insert for the rewrite table and the SQL error gives you the clue.To the UberTheme devs, I suggest if possible you could add this dup check to the fixduplicateurl script as it is completely missing it.

4 answers

Profile photo of ubdev Staff 98550.00 $tone October 4, 2018

Hi there,
Actually, the duplicated URL key issues refer to the conflict between your data with Magento 2 core function.
Our migration tool already verifies the unique category url key, url path; and unqiue product url key, url path. However, this is a special circumstance from your specific data only.
Anyway, glad that you sorted it out at your end.
Please let us know if you run across any other issues, we will work closely with you then.
Ubertheme team

Profile photo of fast.serv 10.00 $tone October 5, 2018

The issue was due to a product and category having the same URL key.
ubdatamigration does not find this, it only looks for products having the same key as another product and vise versa.   Although we finally figured this out manually, I’m just suggesting this script should also look for these duplicates (product and category having same key).    For future customers.

Profile photo of ubdev Staff 98550.00 $tone October 8, 2018

Hi there, 
We’ve sorry for our late response as we’ve just been back to work from our weekend. 
As explained in our previous reply, we find that yours is a specific circumstance. And many users who used our migration tool have not run across the same situation. 
Anyway, we have taken note on your report for future reference if other users cope with a similar issue. 
Ubertheme team


This question is now closed

Written By