I am facing this issue while saving a product programmatically on Magento 2.2.5
In any module, if I do
$this->productRepository->save($product); inside a loop for multiple products. I get:
PDOException: SQLSTATE: Integrity constraint violation: 1062 Duplicate entry 'the-lipstick.html-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID' in /home/dev3/www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228
The error is similar to the one described here : https://www.human-element.com/url-key-specified-store-already-exists-magento-2/
Products save fine with admin area login.
Any suggested fixes so far including the ones modifying the core files (DBStorage.php) do not work on 2.2.5.
What I tried so far: 1. Fix from https://www.human-element.com/url-key-specified-store-already-exists-magento-2/ 2. Fix from https://magento.stackexchange.com/questions/210359/magento-2-product-url-rewrite-issue
Please suggest a solution/fix for M 2.2.5