Link to home
Start Free TrialLog in
Avatar of Jeremy Leys
Jeremy LeysFlag for New Zealand

asked on

Magento 2 - URL key for specified store already exists.

Here is my question with supporting screenshots (let me know if you think I’ve overlooked anything obvious):


We have a Magento 2 multisite setup, with categories set up like so

User generated image
Our issue is that when editing some (but not all) of these categories, in different store views, Magento throws the following error and does not save the data:

User generated image
In this case, the name of the “Supplements” category was edited in the Chinese store view.  It shows the changed value of the name in this view but refreshing the page show that it is not saved at all.

Editing the same category in the default store view does not result in the same issue

Ensuring that the “Default” checkbox is unchecked for the url key field in the Chinese store view makes no difference

User generated image

We have tried removing url rewrites for this category (based on the error message and other posts we have reviewed) but this does not help.

We are running M2 Community 2.1.5.

Traced the issue back to a db save error in the url rewrite table:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '90-3' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`store_id`,`entity_type`,`entity_id`,`request_path`,`target_path`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?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?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?)

Open in new window

So multiple entries are saved into the rewrite table in one go (possibly corresponding to the subcats AND their associated products under the given category.

If I track that particular value back to the urls that are being saved I have this entry in the array”

[167] => Array
        (
            [redirect_type] => 0
            [is_autogenerated] => 1
            [metadata] => 
            [description] => 
            [entity_type] => product
            [entity_id] => 15
            [request_path] => 90-3
            [target_path] => catalog/product/view/id/15
            [store_id] => 3
        )

Open in new window


I can’t see any request paths with “90-3” in it.  There are target paths with “catalog/product/view/id/15” but only for default and nz site.  I’ve tried deleting these but that didn’t help.
Avatar of Jeremy Leys
Jeremy Leys
Flag of New Zealand image

ASKER

Answer from Stackoverflow, testing and validating answer:

90-3 means url key 90 for store_id 3. You must look for two entries which have url key 90. And generally the issue is caused by url key of a product under that category. You could also go to catalog product entity varchar table and search for the product which has url key of 90. I guess 119 is the attribute id for url key. Change url key of that product

http://magento.stackexchange.com/questions/169352/magento-2-url-key-for-specified-store-already-exists
ASKER CERTIFIED SOLUTION
Avatar of Toan Nguyen
Toan Nguyen
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Best solution