2

I have this strange issue with magento 2.3.4.

although I have already this patch Magento official patch

which claims that it solve this I keep having this issue with duplicate urls in my database.

This happened after we insert new products with duplicating old ones. When we duplicate a product and then need to unassign one category we get error:

Could not save product "id" with position 0 to category id

and product can't saved.

If we go to same category and try to remove product from there we get:

Something went wrong. Please try again later

and error in exception:

[2020-03-06 14:26:52] report.CRITICAL: Could not save product "40003" with position 0 to category 1674 {"exception":"[object] (Magento\\Framework\\Exception\\CouldNotSaveException(code: 0): Could not save product \"40003\" with position 0 to category 1674 at /myfolder/public_html/vendor/magento/module-catalog/Model/CategoryLinkRepository.php:90, Magento\\UrlRewrite\\Model\\Exception\\UrlAlreadyExistsException(code: 0): URL key for specified store already exists. at /myfolder/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:304, Magento\\Framework\\Exception\\AlreadyExistsException(code: 0): URL key for specified store already exists. at /myfolder/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:337, Magento\\Framework\\DB\\Adapter\\DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'link.html/mylink.htm' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/wpaper/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:585, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'link.html/mylink.htm' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/wpaper/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'link.html/mylink.htm' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID' at /home/wpaper/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"}

If you check previous error you will see that the link is:

link.html/mylink.htm

we use html at the end. I don't know why this error say htm

What we tried:

1.We used modules even paid for regenerate url rewrite table

2.We made a script and resave all products in our catalog

Nothing helped. After a while we have this issue again

Any ideas?

2
  • i'm having the same error.
    – Tora
    Jul 2, 2020 at 3:10
  • @Tora check my answer....This is the solution
    – G. G.
    Jul 2, 2020 at 11:16

1 Answer 1

2

For whom having the same issue with migrated Magento 1 stores.

In magento 1 there was an attribute in db:

url_path

This is migrated to magento 2 and probably it shouldn't.

So if you truncate this attribute in db directly the issue with duplicate is gone.

We found this after a lot of searching and with little luck.

This is the solution tested and working....Just take a backup your db before.

9
  • @G Yes, I fixed the error by changing the url_path value with url_key.
    – Tora
    Jul 2, 2020 at 11:25
  • @Tora please check the answer as right
    – G. G.
    Jul 2, 2020 at 11:27
  • @G.G.in which table did you truncate ?
    – aravind
    Dec 28, 2020 at 4:49
  • @aravind I didn't truncate a table. I just search url_path attribute and remove the data
    – G. G.
    Dec 28, 2020 at 8:41
  • @G.G.I tried the same, I deleted all entries related to url_path in catalog_product_entity_varchar table. Still the issue exists
    – aravind
    Dec 29, 2020 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.