1

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

2 Answers 2

1

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

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

2
  • this code is not working same issue is there. Note i checked code is going into rewrite function Sep 13, 2019 at 11:41
  • this code is not working with me. Can anyone have solution to help me?
    – huykon225
    Jul 22, 2020 at 4:15

Your Answer

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

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