Every time during try update category I get issue:
Could not save product "53430" with position 0 to category 1593
When edit product and try save I see:
The value specified in the URL Key field would generate a URL that already exists.
To resolve this conflict, you can either change the value of the URL Key field (located in the Search Engine Optimization section) to a unique value, or change the Request Path fields in all locations listed below:
What I do:
I deleted table with url_rewrite
and regenerate again via extension by Oleg Koval:
bin/magento ok:urlrewrites:regenerate
Now I see extension add to url rewrites unique url path example url-1
Still I get the same issue.
Also I check this module:
app/code/<VENDOR>/<MODULE>/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php
:
namespace <VENDOR>\<MODULE>\CatalogUrlRewrite\Model;
class ProductUrlPathGenerator extends \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator
{
/**
* Ignore attribute url_path. Always use url_key instead.
*
* @inheritdoc
*/
public function getUrlPath($product, $category = null)
{
$path = $product->getUrlKey()
? $this->prepareProductUrlKey($product)
: $this->prepareProductDefaultUrlKey($product);
return $category === null
? $path
: $this->categoryUrlPathGenerator->getUrlPath($category) . '/' . $path;
}
}
Tie this in with app/code/<VENDOR>/<MODULE>/etc/di.xml
:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator"
type="<VENDOR>\<MODULE>\CatalogUrlRewrite\Model\ProductUrlPathGenerator" />
</config>
Still no work. Any other solution?