Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category - URL key for specified store already exists. #6531

Closed
magentoman2009 opened this issue Sep 7, 2016 · 10 comments
Closed

Category - URL key for specified store already exists. #6531

magentoman2009 opened this issue Sep 7, 2016 · 10 comments

Comments

@magentoman2009
Copy link

magentoman2009 commented Sep 7, 2016

I have seen this same issue but no real solution to the problem. I have an existing category that when I try to edit the category it displays "URL key for specified store already exists". However, this url key is only being used in the store once. There are no children categories with the same name either. I also checked catalog_category_entity_varchar and url_rewrite just to make sure this url key only exists once and it only exists for the same category that I am trying to edit.

I also tried changing the url key in catalog_category_entity_varchar to something wild that would never be used in our store and removed the url_key all together in url_rewrite and the same thing happened while trying to save. Seems more like a core coding bug than a database problem based on that experiment.

Preconditions

  1. Magento 2.1.1
  2. Imported data via the data migration tool

Has anyone figured out why this is happening?

@orlangur
Copy link
Contributor

orlangur commented Sep 8, 2016

Did you try to place a breakpoint in place where this exception is thrown? You can also track an exact DB query which causes a constraint violation.

There could also exist product or CMS page with the same request path, but as you checked url_rewrite table you would notice this.

@andimov
Copy link
Contributor

andimov commented Sep 8, 2016

@beckindesigns
Thanks for reporting this issue.
Please use our issue reporting template to describe this issue. The template specifies the version and configuration information we need to assess your issue. See the Issue reporting guidelines for more information.

@victor-v-rad
Copy link
Contributor

@beckindesigns
Probably the issue you have relates to the data migration tool. There is a dedicated place https://github.com/magento/data-migration-tool/issues where you can report such problems.

I also tried changing the url key in catalog_category_entity_varchar to something wild that would never be used in our store and removed the url_key all together in url_rewrite and the same thing happened

Have you tried to flush the cache of Magento 2? It could help.

@magentoman2009
Copy link
Author

magentoman2009 commented Sep 8, 2016

@orlangur Can you elaborate on how I can do this?

@victor-v-rad Cache is disabled but I refreshed all of them again, manually deleted contents in var/cache, var/page_cache and var/view_preprocessed. The store is in developer mode as well. I still do not have a clue as to why this is happening.

P.S. I checked the logs and logged the url that it was trying to save and noticed that although editing one category it re-saves all the data for each category and its children categories and every product assigned to those categories. It is too much data to try and determine the exact problem. Not sure why it does this instead of saving just one category like you are doing. This makes finding the issue much more difficult. Any other suggestions in trying to determine the exact cause?

@victor-v-rad
Copy link
Contributor

victor-v-rad commented Sep 14, 2016

@beckindesigns
It is hard to figure out what is wrong in your case
You could share DB dump (remove all passwords before) of Magento 1 and send it through email (find it in my profile https://github.com/victor-v-rad)
We will try to migrate it.

@victor-v-rad victor-v-rad self-assigned this Sep 16, 2016
@victor-v-rad
Copy link
Contributor

Fell free to reopen the issue when you have additional information.

@developer-lindner
Copy link

developer-lindner commented Jan 13, 2017

@victor-v-rad I've got a similar issue with categories where it says 'Url key already exists'.
Even after deleting everything from url_write, catalog_category_entity_varchar and catalog_url_rewrite_product_category table i still getting this error message.

@webdev2009
Copy link

I managed to fix this by removing duplicates products. once they are deleted , run re-index and clear cache.
I used this to find duplicates. hope it helps

SELECT COUNT(DISTINCT entity_id) AS amount, value, entity_id
FROM catalog_product_entity_varchar v
WHERE EXISTS (
SELECT *
FROM eav_attribute a
WHERE attribute_code = "url_key"
AND v.attribute_id = a.attribute_id
AND EXISTS (
SELECT *
FROM eav_entity_type e
WHERE entity_type_code = "catalog_product"
AND a.entity_type_id = e.entity_type_id
)
)
GROUP BY v.VALUE
ORDER BY amount DESC;

@ksiamro
Copy link

ksiamro commented Jan 27, 2017

Quite similar issue #8304

@vikasneoventis
Copy link

0
down vote

I was also facing same issue while adding/editing categories.

Firstly I found there was wrong attribute id in "catalog_category_entity_varchar" table for url_key and url_path. Then I checked the exect attribute_id of both attributes ('url_key' and 'url_path').

e.g in "catalog_category_entity_varchar" table it was showing '117' and '118' but exact id was '119' and '120'. Then I found there was some rows in "catalog_category_entity_varchar" table with these (correct id '119','120').

I followed below steps to resolve issue.

firstly I searched rows in "catalog_category_entity_varchar" where attribute id is in (117,118) and exported the data from table.
then I searched rows in "catalog_category_entity_varchar" where attribute id is in (117,118,119,120) and deleted these data (rows) from table.
then I just opened exported file in notpadd++ then I changed attribute ids 117 with 119 and 119 with 120 and import the data again.

Make sure take the backup of the database before doing above steps.

magento-engcom-team pushed a commit that referenced this issue Jan 21, 2021
[arcticfoxes] B2B-1637: Fix GET_LOCK error on read-only slave connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants