Magento2 : Update category, URL key already exists error
Asked Answered
G

5

7

I have created a new category and its not visible in navigation menu as of now.
I am adding products to it via code and its working.

Now i am editing the category to show in navigation menu, it throws error as "URL key for specified store already exists".

I tried to:
Unassigned products, throws same error.
Changed URL, left blank or changed value of URL.

Please let me know.

Gadid answered 9/5, 2016 at 10:44 Comment(2)
Same here... huge issue!Motorbus
I have same issue, have you found any solution?Magistery
C
0

Clear db table url_rewrite but! for categories only. otherwise it will mess with CMS pages links.

After doing this error should be gone.

Catalogue answered 19/5, 2017 at 13:25 Comment(0)
K
0

1) delete records from "url_rewrite" where entity_type is "category"

2) run php bin/magento php bin/magento indexer:reindex

Kinnard answered 22/1, 2018 at 9:2 Comment(0)
S
0

1) Going your Database

2) Search the url_rewrite and "category" entity_type is Remove

3) And Finally run this command, php bin/magento indexer:reindex

Seem answered 1/2, 2020 at 12:4 Comment(0)
J
0

I had the same problem. Temporarily rename the category URL to something else, clear the cache and rename it to the original URL you had before.

Jehad answered 27/5, 2021 at 7:23 Comment(0)
R
0

Check Existing URL Keys:

Navigate to Catalog > Categories in the Magento admin panel.

Review the URL keys of existing categories to ensure the one you want to use isn’t already in use.

Change the URL Key:

If the URL key is in use, modify your desired category’s URL key to a unique value. You can add a suffix or prefix to differentiate it.

Reindex Data:

After changing the URL key, go to System > Index Management and reindex the data. This can help in clearing any cache and ensuring the changes are recognized.

Clear Cache:

Clear the Magento cache by navigating to System > Cache Management and clicking on “Flush Magento Cache” and “Flush Cache Storage.”

Database Check (if needed):

If you have access to the database, you can run a query to check existing URL keys:

**sql**

SELECT * FROM catalog_category_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_key') AND value = '**your-desired-url-key**';

Replace '**your-desired-url-key**' with the key you want to use.

Check for URL Rewrites:

Check the url_rewrite table in the database to see if the URL key is associated with any old rewrites that might be causing conflicts.

Disable URL Key Generation:

In some cases, disabling the automatic URL key generation might help. You can do this by setting the URL key to empty and saving, then changing it back to your desired key.

Logs and Debugging:

Check Magento logs in var/log for any additional error messages that might provide more insight into the issue.
Remde answered 18/9, 2024 at 10:23 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.