0

I am using Magento 2.3.2 and I am trying to duplicate one of existing SKU from admin I clicked on save and edit and I am getting the following issue.

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:

- all-items/chip-dip-14-3-4.html

- colorwave-serving-pieces/chip-dip-14-3-4.html

- entertain-with-colorwave/chip-dip-14-3-4.html
0

You need to create simple module to fix this like below

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;
        }
    }

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>

reference https://github.com/magento/magento2/issues/12412

  • this code is not working same issue is there. Note i checked code is going into rewrite function – Pradeep Sanku Sep 13 at 11:41
0

URL Key of the product is made by SKU by default, you can duplicate the SKU but not the URL key so where you are trying to duplicate the SKU try to manually set the URL key of the respected productenter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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