-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
"URL key for specified store already exists." cannot save category #7298
Comments
Duplicate #6671 |
That issue because the table Let's run below SQL in your Magento 2 database, you will see the duplicated values:
After run that sql, if you see any rows in result, let's find way to delete that records in the table Hope this help. |
@quynhvv What would be the implication of delete entries from |
@frostshoxx : Let's run below SQL in your database, you will see the records which you have to delete.
|
There's actually nothing return as a result. |
@frostshoxx : So, what happened with below SQLs:
vs
|
@quynhvv the first entry return empty, the 2nd one return 0. Perhaps my store attribute_id for url_key and url_path are not 119, 120? |
I'm closing this issue as a duplicate of #6671 . |
Actually, I think that there are multiple issues here. #6671 has narrowed down to an anchor URL rewrite generator. I suspect that this issue is related but seperate. |
Hi guys, in my case I received a bucket load of this issue. Steps to reproduce my findings:
Result: @quynhvv Thanks for the proposed solution. However, I tried your query, returns 0 rows. |
Same issue here - using the data migration tool from an M1 CE store, cannot save any categories. |
I also encountered this issue after I cleaned the magento database. https://blog.mdnsolutions.com/magento-2-delete-all-categories/ I used the script suggested in this blog and the problem was solved. |
Hi, In my case, the problem was caused by the interruption of a product import. I just needed to remove all the products that had been imported and after that I was able to save the category. The other solutions proposed in this and other tickets didn't work. |
@paugnu Just FYI for others, this did not work in my case. |
it seems something to do with Unicode characters, @zaknixon do you have Unicode characters in your category names? I'm facing the same issue. I suspect my Unicode text on category name ruined auto generated url key and set it null or Unicode characters instead. |
Just an FYI I have had this error come up repeatedly as I have uploaded products. Believe it or not the problem is always the same thing. The category cell length can't exceed 250 characters. Any longer and the error appears. I simply duplicate my row and cut the category in half. First half of categories in the first row and the second half in the next one. Then everything uploads fine. |
@ezprod would you mind sharing the SQL queries that narrowed down the affected products? |
Magento CE 2.1.0, unable to edit/save some existing product categories!
What should I go from here? |
I believe in Varchar is limited to 255. It still utilizes this format for categories even though it breaks it into multiple cells as it reads the poles or commas in the import. |
This Magento 2 bug you can directy fix is changing file File Path :vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php Orginal Code:from
into
After insert this line clear cache. |
@sadeeshmca I tried your fix but it didn't work for me as the error persists as I tried to save my category. I couldn't find your suggested file, in my case I edited: |
0 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.
Make sure take the backup of the database before doing above steps. |
In my case it was enough to set is_anchor=0 for root magento category (entity_id=1) |
I have struggled with this problem for almost a day. It is because of my data migrated from magento V1 to magento V2. There are my solutions: The second one : Remove the duplication data when saving category.
After debugging, i found out $data variable have duplicate record. If you want this method to work without any errors. Rewrite this method above to:
These solutions above both work for me. But the second one is not an ideal solution. I hope it will help. |
@toanthree I like your second option, works great for me, I only added the last line of the old function, that makes it work for real:
|
@toanthree @scher200 guys, as far as I understood an implementation it is not a solution at all. By skipping some request paths it simply makes products inaccessible in some stores using their Please tell me if my observation is wrong as I didn't try this code in action. |
Hi @VladimirZaets. Thank you for working on this issue.
|
Magento Open Source 2.3.3 Steps to reproduce Purpose of redirect is to redirect a direct category nested link to go directly to the product. Most likely for Canonical/SEO purposes. When I go to the category in the admin, I can save the category changing some field values like name, etc. If I set Anchor Yes/No, just toggle the switch and save, I get an error that the URL key already exists. I receive the same error if I attempt to remove the single product from the category or if I go to the product and remove the category there, the same exact error. This product does NOT have a duplicate key. The issue has been narrowed to a URL rewrite. Deleting the URL rewrite fixes the issue, however that is not a workable solution. The company has thousands of URL redirects for varying purposes. URL rewrite management is a valid business function. The raise exception is not logical based on the use case. The raise happens in module-url-rewrite/Model/Storage/DbStorage.php, doReplace() There are many categories that have this issue and the only solution so far is to delete all url rewrites and not create them, which again is not an acceptable solution. I have read at least 2 bug reports on this specific issue dating back to 2016. I do not understand why it is still an issue and is not fixed. |
I am not sure about all cases but I have determined the cause in our case and it is not necessarily a migration issue. For some odd reason, the business created manual redirects from some of the full category paths to the product page directly, probably for some seo reason. ***I suspect that in Magento 2, a new functionality has been made to automatically create a url rewrite from site.com/category/othercategory/product.html to catalog/product/view/id/7550/category/90 - a new type of route |
@aliomattux Thank you for the infos! I will try to have a look at this and talk to core developers at tomorrow's contribution day at MagentoLive Europe. Hopefully, we can find a solution. |
Hi @engcom-Bravo. Thank you for working on this issue.
|
Hi there. Could anyone please give the exact Steps to Reproduce following which the issue is reproducible on the vanilla 2.3-develop instance. @aliomattux I tried to use the info You've shared and if I understand it right I can reproduce somehow a behavior that gives an error. But that error is "The value specified in the URL Key field would generate a URL that already exists..." and not the one this issue is about, i.e., "URL key for specified store already exists". Besides I'm not sure that behavior isn't an expected one. Though Your explanations are very detailed, probably I still miss or misunderstand something. So could You please write more strict Steps to Reproduce something like this:
|
We are closing this issue due to inactivity. If you'd like to update it, please reopen the issue. |
still have this issue, this should not be closed |
still have the issue also , magento 2.3.3 |
Still have an issue on 2.3.3 |
Still have an issue on 2.3.4 |
Got this issue today on 2.3.4 |
This might be relevant to this issue: If you have a parent category with I can't confirm if it exists in all cases, but we are using Elasticsearch which contains the catalog_category_product index and have a "Smart Category" module which handles catalog_category_product index on it's own and whenever a save happens it attempts to check up on url_rewrites. so in our case it might just be this module. I can consistently make it work by attempting to remove the product from the parent category. however if i go to the child category and remove the product, the exception does not happen. afterwards i can then remove the product from the parent category |
Same issue on 2.3.4. I'm using an external module for categories import and it triggers this error. I'm aware now that it's a Magento2 core issue. |
For people who keep running against this, first start by investigating if you don't have invalid url-related data in your catalog, you can use this module for that if you want to. Then try to fix that invalid data (which you sometimes need to do directly in the database since Magento doesn't have an UI for specific data like product or category url_path's for example). If you are importing new products or categories, then make sure the url_key's for them won't cause conflicts with already existing categories/products in your shop or with other categories/products in your import data. Everything needs to be unique, otherwise you'll get into troubles! Hope this helps somehow 🙂 |
I am also facing this issue unable to understand why this is being happened. |
I haven't been following this for a while but did have a quick update. Using Magento 2.3.3 |
@aliomattux: in fact you should clear the |
I am running into this issues on Magento2.3.5pt-2. Is there any fix for this? |
You can install: https://github.com/baldwin-agency/magento2-module-url-data-integrity-checker to find possible bad categories and products if you follow the url_path regeneration feature of magento2 within category save you can see that the problem exists internaly |
@WebKenth Thank you. I will give this a try. I know this module only shows you the problems. Does not fix. If I do find two products that have same url_key do I just manually delete url_key from Magento admin in url rewrites? Or do it from database? What would be the proper way to fix these conflicts? |
@JonathanHelvey Yep or just change the product's url_key to something different I handled it by updating the products url_key with a script that simply adds a number depending on the occurences :P it can probably be done in multiple ways |
@WebKenth, Sounds good thank you for the advice. I guess, I could also go with a paid module that will do it for me. But like the free module says. It can mess with SEO. The paid module is pretty cheap from Magento store. https://marketplace.magento.com/webpanda-catalog-url-rewrites.html. May do this to save time. If your url_key script is an open source project and up on github I would not mind trying your script out as well? If you are willing to share. Otherwise I will do it manually or start writing something out. Thanks for all the help. |
The request_path exceeds 255 and is truncated. If your mysql version is greater than 5.6,You can set the length to be greater than 255 |
Anyone getting this error on M2.4.7-p1 ? |
I've been trying to update/save a specific category but get the message "URL key for specified store already exists." every time.
I don't know if you can replicated it as it's very specific.
Recreate
Message: URL key for specified store already exists. comes up and nothing is saved
Preconditions
Magento ver. 2.1.2
PHP 7
MySQL 5.6
Trouble Shooting:**
url_rewrite
and found no duplicates.delete from url_rewrite where entity_type='product' and entity_id NOT IN (Select entity_id from catalog_product_entity);
select count(*) from url_rewrite where entity_type='product' and entity_id NOT IN (Select entity_id from catalog_product_entity);
Each time I've re-ran the indexer via ssh and cleared all caches, nothing has worked.
Any ideas?
The text was updated successfully, but these errors were encountered: