Skip to content

URL key for specified store already exists - over 51 bugs reported - still not fixed #10265

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

Closed
andidhouse opened this issue Jul 17, 2017 · 16 comments
Labels
Component: CatalogUrlRewrite Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@andidhouse
Copy link

Sry to write one more time here but what is happening here with bugreports?

Search for the bug: "URL key for specified store already exists"

Shows 20 open bugreports and 31 closed ones - AND the issue is still present in ALL magento2 versions including the latest release 2.1.7

I really do not know what is happening here?

@orlangur
Copy link
Contributor

and 31 closed ones

They are closed for a reason. Most of such issues occur when database is filled directly with some migration scripts and after that products/categories appear in unmanageable state.

Here you can read about the difference in URL Rewrites behavior between Magento 1 and Magento 2: #10242 (comment)

Not closed ones are simply not processed yet. Some improvements are done in scope of #6671 (currently a part of 2.2.0-preview) which will allow to determine conflicting URLs more easily.

@andidhouse
Copy link
Author

@orlangur thanks for the feedback.

I am afraid i do not get your approach here.
The Github reports and google search results clearly show that there is a problem with the rewrites (importing, exporting, etc.).

I do not think your approach is right here just to say "it is a problem of some migration scripts" - you can read multiple posts where this occurs also by using the official magento2 migration tool!

Anyways - it is the same like with most bugs reported here. It is not the fault of the magento team and will maybe fixed in 2.x.x - maybe in a year, maybe never.

This approach can be seen here all over and over again to most of the bugs reported.
Instead of bringing a simple fix to the people and overthink the url rewrite behavior at all (you also excluded the url reindex for what reason?) you simply blame other programmers.

Not shure if this is a good approach at all.

@orlangur
Copy link
Contributor

"Bugs" regarding "URL key for specified store already exists" are only reported because of misunderstanding of how URL Rewrites behave in Magento 2 compared to Magento 1. There is nothing to "fix" with it and no simple fix exists at all.

In Magento 1 URL Rewrites were regenerated in background via indexer, it added random numeric suffixes in case of collision and DID NOT preserve previously generated values (this is the main problem from SEO perspective).

In Magento 2 URL Rewrites are generated immediately when you change value in Admin UI, which means you can easily see any collisions and solve them by editing current or conflicting product/category.

"it is a problem of some migration scripts" just means that you will not meet a problem if you enter products via Admin UI or by properly saving product model in script. BUT if you change some database tables directly via some hacky scripts validation will not occur and thus you may meet troubles later.

Is it clear now? How would you suggest to change Magento 2 current behavior?

@korostii
Copy link
Contributor

korostii commented Jul 18, 2017

URL key for specified store already exists is merely an error message. Most errors you see in real life (as opposed to doing development) are an adequate response to user actions which are considered inappropriate or impossible (as, in this case, having duplicate entries in a column having a unique constraint).

It would only be a bug if you're saving, in fact, a unique entry.
..or if Magento2 would have a feature aiming to resolve these conflicts at automagically - one might expect such a feature, having experience working with Magento1, but it's not provided.

What I would argue is that it would be an improvement if this feature was restored (not "fixed", but implemented) - clearly, there's plenty of users who'd like to have it. However, it might also make sense to have it disabled by default for various reasons including the ones mentioned by @orlangur above and some SEO considerations as well (with ability to enable this feature via admin or env.php or whatever).

Anyhow, the point is that having these errors shown to the user is currently considered expected behavior. Thus, if you'd like it changed or removed, the only options suggested by Magento, Inc. are:
a) post a feature request to the Community Forums
b) implement the functionality yourself and create a pull request in order to get it merged into CE

@andidhouse
Copy link
Author

"Bugs" regarding "URL key for specified store already exists" are only reported because of misunderstanding of how URL Rewrites behave in Magento 2 compared to Magento 1

Ok - this may be right - but i think if even your team with the official magento2 data migration tool fails to understand the new logic how can a external developer get it?

The solution for this problem and any problem regarding URLs and URL rewrites is quite simple in my opinion.

--> Include a script which first deletes all URL generated data an 2nd regenerates the data from scratch on.

There are some extensions out there which do that but there are also many problems with these as the logic behind magento2 url rewrites is not reported enough. For example how can it be that if you truncate the url_rewrite table and regenerate it with a script the error "URL key for specified store already exists" still exists?

The logic implemented right now also has a huge downside:
Category save action with thousands of products and hundreds of subcategories takes not 1 or 2 seconds but much much longer. Not a good solution for a efficient workflow at all.

@korostii
Copy link
Contributor

Include a script which first deletes all URL generated data an 2nd regenerates the data from scratch on

This sounds disastrous from SEO perspective. Unless you provide generate accompanying 301 redirects, you'll lose the traffic to these pages from the search engine results.
IMHO Such a behavior shouldn't be the default. You should only do something like that if you know what you're doing, or if it's a website still in development where it doesn't matter at all.

BTW There's some reassuring feedback on the topic provided by a Magento employee quite recently: #10242 (comment)

@andidhouse
Copy link
Author

This sounds disastrous from SEO perspective >
Not at all. 301 redirects should normally be placed not inside magento or any database. Also if 301 are in the magento database they simply can be ignored by a script.

The script just enjures that the settings in the backend (like category urls/ product urls etc) are generated properly.

If you place 301 redirects via the magento interface you should overthink your seo strategy at all ;-)

@orlangur
Copy link
Contributor

For example how can it be that if you truncate the url_rewrite table and regenerate it with a script the error "URL key for specified store already exists" still exists?

It means the data is invalid and contains some collisions which needs to be resolved. You can try 2.2.0-preview branch in action which contains improvements related to #6671 to see where the problem is.

@andidhouse
Copy link
Author

@orlangur thanks - this is clear so far but where does our developer now get the exact function how the url and url-rewrites are generated in magento2. Which tables are included in the generation and how exactly are the url generated. Without this information it takes hours or days to try to suggest what is happening.

@NanthiniMuralidaran
Copy link

I have found a workaround for this: (Tried in magento 2.1.7)

  1. Uncheck MAIN WEBSITE while saving the product
    capture

  2. THEN QUERY IN DB
    INSERT INTO catalog_product_website (
    product_id ,
    website_id
    )
    VALUES (
    '20', '1'
    );
    20- PRODUCT ID
    1-WEBSITE ID
    Note: Before this check catalog_product_entity table has this product id

@andidhouse
Copy link
Author

I think it the problem with this error has something to do with not active categories imported in magento2. These categories set to "disabled" in the backend seem not to be taken into account somehow in the magento2 system if they are imported and caused the error in our case.

We deleted the not active categories and is is fine for the moment for us.

@orlangur
Copy link
Contributor

orlangur commented Sep 4, 2017

@andidhouse I saw a similar bug report recently about "Not Visible Individually" Visibility value not tracked properly from URL Rewrites perspective.

By

not active categories imported in magento2

do you mean 1.x data migration or builtin import? I don't remember exactly but there could also be some "reserving" mechanism which generates URL Rewrites for nonactive categories so that they can be enabled at any moment without any issue.

@andidhouse
Copy link
Author

Hi @orlangur. We used Uber Data migration tool as the native magento2 data migration tool was not working for our sites.

But i think it is caused by the deactivated status (at least in our case) - so i am not shure if m2 handles deactivated categories / products right on import. Maybe this could be checked?

@orlangur
Copy link
Contributor

orlangur commented Sep 4, 2017

Sure, just fill an issue corresponding to https://github.com/magento/magento2/blob/develop/ISSUE_TEMPLATE.md (the main part is observed/expected result) as current issue is hardly manageable.

If some third-party tool built on top of Magento import is not working as expected the problem could be in tool itself also, ideally if the tool vendor would identify piece of Magento import code which causes a bug.

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Component: CatalogUrlRewrite labels Sep 11, 2017
@orlangur
Copy link
Contributor

System behaves normally in current implementation if your data is valid in the first place. If https://github.com/magento/data-migration-tool produces invalid data in some cases, it should be reported.

@andidhouse
Copy link
Author

I am 100% shure this will come up again - so this is closed and then another ticket is created. I am not shure what the meaning of this is as this was reported in different forums several times again and again.

But ok - lets see what happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CatalogUrlRewrite Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests

5 participants