Magento2: Issue with Product Import - "Category has not been created. URL key for specified store already exists"

Created on 27 Jan 2017  路  9Comments  路  Source: magento/magento2

Preconditions

Magento 2.1.3
PHP 7.0.8

Steps to reproduce

I'm trying to import 2 product with similar categories but on different parents.
First Try:
https://i.stack.imgur.com/ldhOD.png
Second Try:
https://i.stack.imgur.com/vJmZd.png

Expected result

Import successful. Categories created with no problems.

Actual result

First Try:

Category "MAN/zakiet/zakiet" has not been created. URL key for specified store already exists. in row(s): 2

Categories:
https://i.stack.imgur.com/PeRWN.png

Second Try (without delete previous categories):

Category "Default Category/WOMEN/zakiet/zakiet" has not been created. URL key for specified store already exists. in row(s): 1, 2

Categories:
https://i.stack.imgur.com/kEKiM.png

However I am able to create those categories manually with no problems.

Catalog CatalogUrlRewrite ImportExport Cannot Reproduce Format is valid Ready for Work bug report

All 9 comments

It happens when You try create similar categories in other root category. It happens because firs category won't be include in url rewrites. Eg:

First Default Category -> Test1 -> Test2
create paths:
/test1.html and /test1/test2.html

When You try to create :

Second Default Category -> Test1 -> Test2 Magento will create rewrite with paths:
/test1.html and /test1/test2.html also.

Solve:
Try to set different url category or use one root category.

I have a solution packed in an extension which can regenerate the category URLs using the CLI. Contact me if you need it.

@ksiamro

Please clarify how to fix this issue.
Do you mean change the url key of the category?

Update

Seems to work when you do

DELETE FROM url_rewrite
WHERE request_path LIKE '%category-name%';

Hi, @ksiamro. Internal ticket MAGETWO-70856, which tracks this GitHub issue, is in our issue backlog.

@ksiamro, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

I can verify that this is an issue. I'm using Magento 2.2.2. Category is in the admin. I created a product in backend using category, exported products to verify and used that category text from exported csv to include in the other csv. I've re-indexed, cleared cache, nothing seems to work.

Same Issue in Version 2.2.1
Same category names under different root categories

My problem was because my category name had an extra space at the end in the import file field.

CSV Import must trim cells. Still a problem in Magento 2.3.0 @magento-engcom-team

Was this page helpful?
0 / 5 - 0 ratings