-
Notifications
You must be signed in to change notification settings - Fork 9.4k
URL key for specified store already exists in Magento 2.1.1 #6671
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
Comments
Hi @sanjayjethva, Please format your issue description according to the Issue reporting guidelines. |
This problem happens when you have product and category with the same url key. Example: 1.- Create Category: Energy Products(URL Key:energy-products) |
I can confirm, same problem on Magento 2.1.1 |
Hello @mgomez-dgt Thanks and let me know |
same problem while updating an product with category changes |
Similiar problem here, but touches product-category relations. Removing product-category assignment allows you to save the product without having "URL key for specified store already exists." (but of course is not desirable for any store owners out there).
It seems like there's something wrong with category update mechanism. I went ahead saving categories one by one and pinpointed the troubling category to: and seen there's really no url in database so made it:
then run: now the url would appear in the admin edit form but of course still after trying to save it: I went ahead and added url keys manually to the DB and updated url_rewrite manually aswell. still can't save that product with categories assigned... We need to go deeper then....
and that got me the error I needed: Considering the result of
So the problem seems to be in categories 1 & 2 which, through the admin panel, I cannot update url keys for. And that leads us to some hints for why custom imports fail here and why shop, where the customer accidentally removed his root category (which was later readded) fails. Edit: dirty fix is changing
into
M2 team: please fix root category handling and that should fix those. |
@miakusha ☝️ there's your update ;) |
I'm having the same issue as well. Is it being fixed, so should I just do the dirty fix to get the ball rolling? I tried to update DbStorage.php per @janmyszkier recommendation, but the error |
Can confirm this is happening with 2.1.2 EE as well. |
@frostshoxx it's like your root category has a different ID than the one in @janmyszkier's example code |
Confirmed in M2.1.2 I have 2 categories that have similar sub-category names (For example foo/bar, goo/bar). 'bar' is considered a duplicate key. Fun fact: truncating the url_rewrite table did solve the problem for me. |
I managed to fix this in the end, I would recommend not emptying your We had multiple stores, and products from store A were associated to categories under store B. At a high level this is what I can tell was happening:
|
@jameshalsall How did you manage to fix this issue in the end? |
👎 for @magento-team for leaving this issue unresolved for so long with not even a workaround. |
@frostshoxx I removed the associations of products to categories that were cross-store, if that makes sense. EDIT: I think this could be a problem with the save + duplicate feature, when you're editing a product from one store and then duplicate it to the other store it may keep the category associations from the original store. |
The url regeneration process is large/implicit and complex to keep all the main entities in e-commerce industry (products and categories) accessible to customers. FlowThe flow is next:
Actual problemThe error shown on frontend is "URL key for specified store already exists." but actual error message which is generated by DB engine is next: Used environmentEnvironment is next:
Causes explanationThe problem is caused by using of array_merge (1st) for combining all the url rewrites generated and by anchor URL rewrites generation procedure (2nd): Second is using categoryRepository in internals for obtaining category objects which opens a possibility to use inconsistent/outdated data and first one makes it possible to overwrite correctly generated data with wrong data from anchor URL generation. In our case the problem was and still is with product rome-umbrella-lane which belonds to the category women's accessories (URL key is womes-s-accessories). When the user fills new url_path (women-accessories) the the whole process is run and during the anchor generation one products category is in fact child category for edited one:
scarves category is child of women-s-accessories and parent category is marked as anchor:
In $this->categoryRepository->get($anchorCategoryId) category object is fetched from cache:
Problem causeproduct is assigned directly to edited category (while editing url_key) and assigned to one of child category and edited category marked as anchor. Options of resolving for Magento TeamThe solution is not clear at first glance but there are few options:
Options for us until Magento 2 releaseOne of the options which is available for client project developers - apply complex solution with few rewrites via preference for categoryRepository to add instances cache invalidation method and anchorURLRewriteGeneration with usage of added method but obviously this isn't recommended at all bc can affect different parts of the functionality. Hope this will help to fix this issue finally. |
Currently I'm patching these issues (incorrect anchor URLs and not generating URLs for multiple stores) by:
Obviously I now need to make these into plugins or preferences, but can anyone see a problem with these fixes? |
After my changes the errors go away in some cases. Still getting the error sometimes. Trying to track down exactly when. |
I'm trying it local now as well. But the weird part is: earlier, when I truncated the |
@kanduvisla if you look at the example you'll see that I didn't have them either and the error was there because it tried to INSERT them (which failed). not because they were already in the database. |
i was getting the same error, i fixed mine by removing duplicated data from the product url-keys. |
I tried the fix mentioned by janmyszkier. At first I could save the category. On a second save I get the error again :( |
[Jackalopes] [Okapis] Combined PR - MAGETWO-66480 [GITHUB] URL key for specified store already exists #6671 - MAGETWO-67296 String localization is not working when phrase contains quote (') - MAGETWO-69657 Credit Card Information disappear after user enters promotion code - MAGETWO-63249 [Elasticsearch] Composite products not searchable
@cpartica @buskamuza can you backport fix for this issue to 2.1.x branch also? |
@Koc , there is an internal ticket for it as mentioned above. Unfortunately, I can't say anything about time line as it should be prioritized. |
@cpartica Can you provide a patch for 2.1.x ? Or backport it into 2.1.8 ? |
Hi guys, Let's try my solutions issue #7298. Hope this help. |
@cpartica I would also like to see a patch that we can apply to 2.1.x. This issue is causing no end of grief for my client's ecommerce site. |
agreed, please guys, sort this out. SEO nightmare
…On Sun, Jul 23, 2017 at 10:12 PM, Christopher Staley < ***@***.***> wrote:
@cpartica <https://github.com/cpartica> I would also like to see a patch
that we can apply to 2.1.x. This issue is causing no end of grief for my
client's ecommerce site.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6671 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AV1NbbFcEZKrWTmHuPY675qUQhLI9iw6ks5sQ5sygaJpZM4KBPCb>
.
|
Has anyone figured out how to apply MAGETWO-66480 to 2.1.7? |
Hey @christopher-s, We have created the changes as core fixes for ourselfs and then reworked those to create the PR. There is some difference in the way the URL rewrites are handled between Magento 2.1 and 2.2 so the code is a bit different, but you can look at my changes in the PR and create a solution for Magento 2.1 from it if you like. Please upvote / like the PR, because there is quite a discussion going on and I think the more people agree with the changes and get involved with the discussion will convince the core team to look at this more seriously. |
@dverkade the fix is included in the latest version (2.1.9)? |
Its not posted as a fix in 2.1.9 KB, and it just failed G1 testing by the engineering team. So I'd say no. |
@sanjayjethva, thank you for your report. |
Uh oh!
There was an error while loading. Please reload this page.
I am facing "URL key for specified store already exists" error when i am trying to update existing category name as its appearing in some categories.
I am using Magento 2.1.1.
I have read so many articales where it stated that it is solved in magento 2.1 version but its appearing again. Let me know
Please help me to resolve the issue.
Thanks
Preconditions
Magento 2.1.1
Steps to reproduce
Try to update the name of existing category as its appearing in some categories
Expected result
Category's name is updated
Actual result
"URL key for specified store already exists" error
The text was updated successfully, but these errors were encountered: