1
Migrated Magento 1.9.4 --> Magento 2.4.2-p1

We migrated all data except orders from our production Magento 1.9.4 site to Magento 2.4.2-p1. Everything seems to work in the new Magento except when we copy an existing product or when I tried to move a category into another category, I get the following error:

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:

and then 9 products listed here

I googled this but all I find are never-ending discussions and super-complicated steps to try. Is there a simple to implement the solution I could do to fix this?

Here are my entries from exception.log:

[2021-08-01 15:49:02] main.CRITICAL: URL key for specified store already exists. {"exception":"[object] (Magento\\UrlRewrite\\Model\\Exception\\UrlAlreadyExistsException(code: 0): URL key for specified store already exists. at /home/myWEBSITE/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:309, Magento\\Framework\\Exception\\AlreadyExistsException(code: 0): URL key for specified store already exists. at /home/myWEBSITE/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:342, Magento\\Framework\\DB\\Adapter\\DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `mget_url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:599, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `mget_url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID' at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []
[2021-08-01 15:49:03] main.WARNING: Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg at /home/myWEBSITE/public_html/vendor/magento/framework/Filesystem/Driver/File.php:95)"} []
[2021-08-01 15:49:19] main.WARNING: Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg at /home/myWEBSITE/public_html/vendor/magento/framework/Filesystem/Driver/File.php:95)"} []
[2021-08-01 15:50:43] main.CRITICAL: URL key for specified store already exists. {"exception":"[object] (Magento\\UrlRewrite\\Model\\Exception\\UrlAlreadyExistsException(code: 0): URL key for specified store already exists. at /home/myWEBSITE/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:309, Magento\\Framework\\Exception\\AlreadyExistsException(code: 0): URL key for specified store already exists. at /home/myWEBSITE/public_html/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:342, Magento\\Framework\\DB\\Adapter\\DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `mget_url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:599, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `mget_url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'fabbri-amarena-cherries-panettone-1000-gram-www-MYstore2-com.' for key 'MGET_URL_REWRITE_REQUEST_PATH_STORE_ID' at /home/myWEBSITE/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []
[2021-08-01 15:50:44] main.WARNING: Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg at /home/myWEBSITE/public_html/vendor/magento/framework/Filesystem/Driver/File.php:95)"} []
[2021-08-01 18:08:19] main.WARNING: Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /home/myWEBSITE/public_html/pub/media/catalog/product/f/a/fabbri_amarena_cherries_panettone_1000_gram_www.MYstore2.com_2.jpg at /home/myWEBSITE/public_html/vendor/magento/framework/Filesystem/Driver/File.php:95)"} []

I tried changing the URL Key for the first product and then moving the category again but it comes up with the same Error including a reference to the URL key of the first product (even though I changed it already).


Edited on August 5th, 2021:

I've googled this and all the answers are quite complicated. I'm looking for a step-by-step solution as in doing #1, then #2, then #3... and done!


UPDATED on August 9th, 2021:

I don't understand how to do what @Jitendra Patel or @Rk Rathod propose so I have tried doing what @Daniel Ifrim suggested = I've downloaded the Zipped file from Github, unzipped it, and copied the files over via FTP (into www.MYwebsite.com/app/code/OlegKoval/RegenerateUrlRewrites). It then says to enable the extension by running:

$> PHP bin/magento module:enable OlegKoval_RegenerateUrlRewrites

I did that but that gave the following Error:

The "/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php" file can't be deleted. Warning! unlink(/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php" file can't be deleted. Warning! unlink(/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php): Permission denied
[MYstore@node1340 bin]$ php magento module:enable OlegKoval_RegenerateUrlRewrites

I then proceeded to run the following as it is in the instructions:

$> php bin/magento setup:upgrade

Cache types config flushed successfully
Cache cleared successfully
File system cleanup:
/home/MYstore/public_html/generated/code/Amazon
/home/MYstore/public_html/generated/code/Composer
/home/MYstore/public_html/generated/code/Dotdigitalgroup
/home/MYstore/public_html/generated/code/Klarna
/home/MYstore/public_html/generated/code/Magento
The "/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Magento/Framework/Encryption/CryptFactory.php): Permission denied
/home/MYstore/public_html/generated/code/Migration
The "/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Migration/ResourceModel/Record/CollectionFactory.php): Permission denied The "/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php" file can't be deleted. Warning!unlink(/home/MYstore/public_html/generated/code/Migration/Handler/ManagerFactory.php): Permission denied
/home/MYstore/public_html/generated/code/PayPal
/home/MYstore/public_html/generated/code/Psr
/home/MYstore/public_html/generated/code/ReCaptcha
/home/MYstore/public_html/generated/code/Symfony
/home/MYstore/public_html/generated/code/Yotpo
/home/MYstore/public_html/pub/static/adminhtml
/home/MYstore/public_html/pub/static/deployed_version.txt
/home/MYstore/public_html/pub/static/frontend
/home/MYstore/public_html/var/view_preprocessed/pub
Updating modules:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

I then used it by running the following command:

$> php bin/magento ok:urlrewrites:regenerate --entity-type=product

and the result was:

https://api.fondy.eu/s/aeOD4YCieqKE7U
----------------------------------------------------


[Type: product, Store ID: 0, Store View code: admin]:
[=======================================================================] 100%  2000/2000

[Type: product, Store ID: 1, Store View code: default]:
[=======================================================================] 100%  1192/1192

[Type: product, Store ID: 2, Store View code: store2]:
[=======================================================================] 100%  1255/1255

[Type: product, Store ID: 3, Store View code: store3]:
[=======================================================================] 100%  762/762

[Type: product, Store ID: 4, Store View code: store4]:
[=======================================================================] 100%  134/134

[Type: product, Store ID: 5, Store View code: store5]:
[=======================================================================] 100%  16/16


Reindexation... Done
Cache refreshing... Done
If you use some external cache mechanisms (e.g.: Redis, Varnish, etc.) - please, refresh this external cache.

----------------------------------------------------
Please, support me on:
https://www.patreon.com/olegkoval
https://api.fondy.eu/s/aeOD4YCieqKE7U
----------------------------------------------------

Finished

But now when trying to load the front page or the Admin panel - I get the following Error (I enabled exception printing):

There has been an error processing your request
Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.
The following modules are outdated:
OlegKoval_RegenerateUrlRewrites schema: current version - none, required version - 1.6.0
OlegKoval_RegenerateUrlRewrites data: current version - none, required version - 1.6.0
Error log record number: 1e2aecd1099a08d05c03a1f4c9d0636800a8b875e0ed09bdf22c34b68c2b76a8

UPDATED later on August 9th, 2021:

I've escalated this to my hosting company and they installed Elasticsearch. I then re-ran these commands:

php bin/magento setup:upgrade

and

php bin/magento ok:urlrewrites:regenerate --entity-type=product

When I tried to move the category again - it gave me the same Error but only with 2 specific URLs (I wonder why that even happened since the RegenerateUrlRewrites should have rewritten all the products' URLs?). I clicked the link in the Error and changed the URLs manually and it works now = it moved one category inside the other just as intended.

5
  • Hi, Did you reindex and cleaned cache to make sure the flat data are good ?
    – Claims
    Commented Aug 1, 2021 at 21:48
  • @Claims I just did it again = cleared all Cache and reindexed via SSH (Putty) and I have the same problem.
    – Allysin
    Commented Aug 2, 2021 at 7:44
  • You can regenerate the URLs: github.com/olegkoval/magento2-regenerate_url_rewrites Commented Aug 6, 2021 at 10:03
  • @Daniel Ifrim I tried to do what you suggested but ran into trouble (the website is down). Would you please check my Updated comment from today in the original post? Thank you.
    – Allysin
    Commented Aug 9, 2021 at 17:01
  • @Daniel Ifrim - I installed the extension from Github. The issue I think was with the fact that I didn't have ElasticSearch installed. I ran the command and it seemed to go through but oddly enough - I still got the Error but only with 2 specific URLs. I corrected those manually and was able to move the category as intended. Would you happen to know why this extension did not seem to do the URLrewrite job fully? I updated the original post. Thank you.
    – Allysin
    Commented Aug 9, 2021 at 20:48

3 Answers 3

1
+100

The following approach works fine for me to resolve the below issue.

"URL key for specified store already exists."

Step: 1 First, I have found the above message by using the grep command. Basically below vendor core file throws this message.

File Name : Magento\UrlRewrite\Model\Storage\DbStorage.php

Step 2: Added below log code in the doReplace() method.

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/Categories_debug_'.date('F Y').'.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('---------- Testing Start Here...');
$logger->info(print_r($urlConflicted,1));

![enter image description here

Step 3: Open generated logfile from var/log folder, you can find the product or category which was causing this error. you need to change the request path of the product from admin SEO Tabs for single or for bulk you can search in the catalog_product_entity_varchar table.

Example of log file like as below.

2021-04-12T15:29:35+00:00 INFO (6): ---------- Testing Start Here...
2021-04-12T15:29:35+00:00 INFO (6): Array
(
    [5505] => Array
        (
            [redirect_type] => 0
            [is_autogenerated] => 1
            [metadata] => {"category_id":"318"}
            [description] => 
            [entity_type] => product
            **[entity_id] => 35729** // Your product id
            [request_path] => apparelstest/shorts
            [target_path] => catalog/product/view/id/35729/category/318
            [store_id] => 1
        )

)
0

Refernce Link

Using Preference :-

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\UrlRewrite\Model\Storage\DbStorage" type="Scriptlodge\UrlRewrite\Model\Storage\DbStorage" />
</config>

Vendor/Module/Model/Storage/DbStorage.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Vendor\Module\Model\Storage;

use Magento\Framework\DB\Select;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite as UrlRewriteData;

class DbStorage extends \Magento\UrlRewrite\Model\Storage\DbStorage
{
    /**
     * @param UrlRewrite[] $urls
     *
     * @return void
     */
    private function deleteOldUrls(array $urls)
    {
        $oldUrlsSelect = $this->connection->select();
        $oldUrlsSelect->from(
            $this->resource->getTableName(self::TABLE_NAME)
        );
        /** @var UrlRewrite $url */
        foreach ($urls as $url) {
            $oldUrlsSelect->orWhere(
                $this->connection->quoteIdentifier(
                    UrlRewrite::ENTITY_TYPE
                ) . ' = ?',
                $url->getEntityType()
            );
            $oldUrlsSelect->where(
                $this->connection->quoteIdentifier(
                    UrlRewrite::ENTITY_ID
                ) . ' = ?',
                $url->getEntityId()
            );
            $oldUrlsSelect->where(
                $this->connection->quoteIdentifier(
                    UrlRewrite::STORE_ID
                ) . ' = ?',
                $url->getStoreId()
            );
        }

        // prevent query locking in a case when nothing to delete
        $checkOldUrlsSelect = clone $oldUrlsSelect;
        $checkOldUrlsSelect->reset(Select::COLUMNS);
        $checkOldUrlsSelect->columns('count(*)');
        $hasOldUrls = (bool)$this->connection->fetchOne($checkOldUrlsSelect);

        if ($hasOldUrls) {
            $this->connection->query(
                $oldUrlsSelect->deleteFromSelect(
                    $this->resource->getTableName(self::TABLE_NAME)
                )
            );
        }
    }

    public function doFindAllByDataUrl(array $urls)
    {
        $oldUrlsSelect = $this->connection->select();
        $oldUrlsSelect->from(
            $this->resource->getTableName(self::TABLE_NAME)
        );

        /** @var UrlRewrite $url */
        foreach ($urls as $url) {
            $oldUrlsSelect->orWhere(
                $this->connection->quoteIdentifier(
                    UrlRewrite::ENTITY_TYPE
                ) . ' = ?',
                $url->getEntityType()
            );

            $oldUrlsSelect->where(
                $this->connection->quoteIdentifier(
                    UrlRewrite::ENTITY_ID
                ) . ' = ?',
                $url->getEntityId()
            );
            $oldUrlsSelect->where(
                $this->connection->quoteIdentifier(
                    UrlRewrite::STORE_ID
                ) . ' = ?',
                $url->getStoreId()
            );
        }
        $__hasOldUrls = $this->connection->fetchAll($oldUrlsSelect);
        $data=[];
        if(count($__hasOldUrls)>0) {
            foreach ($__hasOldUrls as $hasOldUrl) {
                $data[] = $hasOldUrl['request_path'];
            }
        }
        return $data;

        //return $hasOldUrls = $this->connection->fetchAll($oldUrlsSelect);

    }


    /**
     * @inheritDoc
     */
    protected function doReplace(array $urls)
    {
        $this->deleteOldUrls($urls);
        //$foundurls= $this->doFindAllByDataUrl($urls);
        $data = [];
        $urlConflicted = [];
        foreach ($urls as $url) {
            $urlFound = $this->doFindOneByData(
                [
                    UrlRewriteData::REQUEST_PATH => $url->getRequestPath(),
                    UrlRewriteData::STORE_ID => $url->getStoreId(),
                ]
            );
            if (isset($urlFound[UrlRewriteData::URL_REWRITE_ID])) {
                $urlConflicted[$urlFound[UrlRewriteData::URL_REWRITE_ID]] = $url->toArray();
                continue;
            } else {
                $data[] = $url->toArray();
            }

            /*if(!in_array($url->getRequestPath(),$foundurls)){
                $data[] = $url->toArray();
            }else{
                continue;
            }*/
        }

        try {
            $this->insertMultiple($data);
        } catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
            /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[] $urlConflicted */
            $urlConflicted = [];
            foreach ($urls as $url) {
                $urlFound = $this->doFindOneByData(
                    [
                        UrlRewriteData::REQUEST_PATH => $url->getRequestPath(),
                        UrlRewriteData::STORE_ID => $url->getStoreId(),
                    ]
                );
                if (isset($urlFound[UrlRewriteData::URL_REWRITE_ID])) {
                    $urlConflicted[$urlFound[UrlRewriteData::URL_REWRITE_ID]] = $url->toArray();
                }
            }
            if ($urlConflicted) {
                throw new \Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException(
                    __('URL key for specified store already exists.'),
                    $e,
                    $e->getCode(),
                    $urlConflicted
                );
            } else {
                throw $e->getPrevious() ?: $e;
            }
        }

        return $urls;
    }

}
4
  • Thank you for your suggested solution. I have created the directories and placed files inside them as suggested, deleted Cache and re-indexed but the same Error comes up. I tried to go to the files on the front end as follows but it just loads up the front page: MYWEBSITE.com/vendor/etc/di.xml and MYWEBSITE.com/vendor/module/model/storage/DbStorage.php I've put the folder names in small letters and copied the file name exactly the same. Does the first letter of the folder names need to be capital? Or is there something else I need to do to execute this? Thank you.
    – Allysin
    Commented Aug 6, 2021 at 14:25
  • MYWEBSITE.com/vendor/module/etc/di.xml path should be this and also please put capital later only. Commented Aug 9, 2021 at 6:24
  • and check working or not Commented Aug 9, 2021 at 6:24
  • This doesn't seem to be working. I tried it with all small letters first but it just loads up the front page when I try to go to the URL. I don't think I can change 'vendor' to capital as it has a lot of other folders inside. I tried it with 'Module' but no luck. What exactly suppose to happen? Do I need to go to that URL to start some kind of a process?
    – Allysin
    Commented Aug 9, 2021 at 13:24
0

I have 2 solutions for that.

The first one: Clean up your database in table url_rewrite (Change the url_key of all categories). You can write the UpgradeData script for this solution.

The second one: Remove the duplication data when saving the category. This data is throw in method doReplace($urls) in `\vendor\magento\module-url-rewrite\Model\Storage\DbStorage.PHP file.

protected function doReplace($urls)
    {
        foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData) {
            $urlData[UrlRewrite::ENTITY_TYPE] = $type;
            $this->deleteByData($urlData);
        }
        $data = [];
        foreach ($urls as $url) {
            $data[] = $url->toArray();
        }
        $this->insertMultiple($data);
    } 

If you want to get more details. Please refer here for more information: https://github.com/magento/magento2/issues/7298#issuecomment-317142133

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.