Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"URL key for specified store already exists." cannot save category #7298

Closed
janeblonde opened this issue Nov 3, 2016 · 97 comments
Closed

"URL key for specified store already exists." cannot save category #7298

janeblonde opened this issue Nov 3, 2016 · 97 comments
Assignees
Labels
Component: UrlRewrite Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@janeblonde
Copy link

janeblonde commented Nov 3, 2016

I've been trying to update/save a specific category but get the message "URL key for specified store already exists." every time.

I don't know if you can replicated it as it's very specific.

Recreate

  1. go to Products > Categories
  2. Select the Category
  3. Click Save

Message: URL key for specified store already exists. comes up and nothing is saved

Preconditions

Magento ver. 2.1.2
PHP 7
MySQL 5.6

Trouble Shooting:**

  1. I've checked the DB table url_rewrite and found no duplicates.
  2. Ran the following queries to clean out possible duplicates (see here):

delete from url_rewrite where entity_type='product' and entity_id NOT IN (Select entity_id from catalog_product_entity);

select count(*) from url_rewrite where entity_type='product' and entity_id NOT IN (Select entity_id from catalog_product_entity);

Each time I've re-ran the indexer via ssh and cleared all caches, nothing has worked.

Any ideas?

@quienti
Copy link
Contributor

quienti commented Nov 3, 2016

Duplicate #6671

@quynhvv
Copy link

quynhvv commented Nov 4, 2016

@janeblonde :

That issue because the table catalog_product_entity_varchar has duplicate values of (store_id, value) with attributes: url_key (119) vs url_path (120) See more about these attributes: http://i.prntscr.com/8604a114212f4661a8f52b48576fe6f0.png

Let's run below SQL in your Magento 2 database, you will see the duplicated values:

SELECT * FROM `catalog_product_entity_varchar` WHERE `attribute_id` IN (119, 120) AND `value_id` NOT IN (
    SELECT `value_id` FROM `catalog_product_entity_varchar` WHERE `attribute_id` IN (119, 120) GROUP BY `store_id`, `value`
)

After run that sql, if you see any rows in result, let's find way to delete that records in the table catalog_product_entity_varchar
And then the issue will be solved.

Hope this help.
Regards,
Quynhvv

@frostshoxx
Copy link

@quynhvv What would be the implication of delete entries from catalog_product_entity_varchar?

@quynhvv
Copy link

quynhvv commented Nov 4, 2016

@frostshoxx : Let's run below SQL in your database, you will see the records which you have to delete.

SELECT * FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120) AND value_id NOT IN (
SELECT value_id FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120) GROUP BY store_id, value
)

@frostshoxx
Copy link

There's actually nothing return as a result.

@quynhvv
Copy link

quynhvv commented Nov 4, 2016

@frostshoxx : So, what happened with below SQLs:

SELECT count(value_id) FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120) GROUP BY store_id, value

vs

SELECT count(value_id) FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120)

@frostshoxx
Copy link

@quynhvv the first entry return empty, the 2nd one return 0. Perhaps my store attribute_id for url_key and url_path are not 119, 120?

@veloraven
Copy link
Contributor

I'm closing this issue as a duplicate of #6671 .

@maderlock
Copy link

Actually, I think that there are multiple issues here. #6671 has narrowed down to an anchor URL rewrite generator. I suspect that this issue is related but seperate.

@dharake
Copy link

dharake commented Feb 23, 2017

Hi guys, in my case I received a bucket load of this issue.

Steps to reproduce my findings:

  • I imported products from a Magento 1.9 store to 2.1.4
  • I exported the CSV, cleaned up some data and tried to import it back.
  • I get around 50-100 of these url_rewrite errors (Specified URL key already exists)
  • I go and change every one of the urls in the CSV manually, upload and its imported fine with all my changes (except attribute_set_code, working solution for that issue is available on request).
  • Now, to confirm, if I look at the product url_key in the backend on a product whose url_key I rewrote, "item-a" -> "item-a-1" for example.
  • Export the csv. Reupload the csv with no changes

Result:
Don't you know it, the new url_key "item-a-1" gets the (Specified URL key already exists) error again.

@quynhvv Thanks for the proposed solution. However, I tried your query, returns 0 rows.

@pixiemediaweb
Copy link

Same issue here - using the data migration tool from an M1 CE store, cannot save any categories.

@lkc299
Copy link

lkc299 commented Feb 28, 2017

I also encountered this issue after I cleaned the magento database.
At last I found the sql script I used was incomplete and some data still remained in database.

https://blog.mdnsolutions.com/magento-2-delete-all-categories/

I used the script suggested in this blog and the problem was solved.

@paugnu
Copy link

paugnu commented Apr 25, 2017

Hi,

In my case, the problem was caused by the interruption of a product import. I just needed to remove all the products that had been imported and after that I was able to save the category. The other solutions proposed in this and other tickets didn't work.

@zaknixon
Copy link

@paugnu Just FYI for others, this did not work in my case.

@sdasun
Copy link

sdasun commented Apr 26, 2017

it seems something to do with Unicode characters, @zaknixon do you have Unicode characters in your category names? I'm facing the same issue. I suspect my Unicode text on category name ruined auto generated url key and set it null or Unicode characters instead.

@ezprod
Copy link

ezprod commented May 10, 2017

Just an FYI I have had this error come up repeatedly as I have uploaded products. Believe it or not the problem is always the same thing. The category cell length can't exceed 250 characters. Any longer and the error appears. I simply duplicate my row and cut the category in half. First half of categories in the first row and the second half in the next one. Then everything uploads fine.

@Tjitse-E
Copy link
Contributor

@ezprod would you mind sharing the SQL queries that narrowed down the affected products?

@eharvest
Copy link

eharvest commented May 16, 2017

Magento CE 2.1.0, unable to edit/save some existing product categories!

SELECT * FROM catalog_product_entity_varcharWHEREattribute_idIN (119, 120) ANDvalue_idNOT IN ( SELECTvalue_idFROMcatalog_product_entity_varcharWHEREattribute_idIN (119, 120) GROUP BYstore_id, value ) returns nothing

SELECT count(value_id) FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120) GROUP BY store_id, value gives me 568 total
SELECT count(value_id) FROM catalog_product_entity_varchar WHERE attribute_id IN (119, 120) gives me 573

What should I go from here?

@ezprod
Copy link

ezprod commented May 16, 2017

I believe in
catalog_category_entity_varchar

Varchar is limited to 255. It still utilizes this format for categories even though it breaks it into multiple cells as it reads the poles or commas in the import.

@sadeeshmca
Copy link

This Magento 2 bug you can directy fix is changing file

File Path :vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php

Orginal Code:

from

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

into

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

     /* Add this line : Get rid of rewrite for root Magento category to unduplicate things
    foreach($data as $key =>$info){
            if(isset($info['target_path']) && stristr($info['target_path'],'/category/1') && $info['entity_type']=='product'){
                    unset($data[$key]);
            }
    }

    $this->insertMultiple($data);
}

After insert this line clear cache.

@eharvest
Copy link

@sadeeshmca I tried your fix but it didn't work for me as the error persists as I tried to save my category. I couldn't find your suggested file, in my case I edited:
app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php
I have fixed some of these problematic categories by exclude certain products, it looks like those products were created wrong, maybe they been duplicated without changing the url key? I never had such issue until I handed over to the client when they started messing around with duplicate products.

@vikasneoventis
Copy link

0
down vote

I was also facing same issue while adding/editing categories.

Firstly I found there was wrong attribute id in "catalog_category_entity_varchar" table for url_key and url_path. Then I checked the exect attribute_id of both attributes ('url_key' and 'url_path').

e.g in "catalog_category_entity_varchar" table it was showing '117' and '118' but exact id was '119' and '120'. Then I found there was some rows in "catalog_category_entity_varchar" table with these (correct id '119','120').

I followed below steps to resolve issue.

firstly I searched rows in "catalog_category_entity_varchar" where attribute id is in (117,118) and exported the data from table.
then I searched rows in "catalog_category_entity_varchar" where attribute id is in (117,118,119,120) and deleted these data (rows) from table.
then I just opened exported file in notpadd++ then I changed attribute ids 117 with 119 and 119 with 120 and import the data again.

Make sure take the backup of the database before doing above steps.

@ifuents
Copy link

ifuents commented Jul 21, 2017

In my case it was enough to set is_anchor=0 for root magento category (entity_id=1)

@toan-tam
Copy link

toan-tam commented Jul 22, 2017

I have struggled with this problem for almost a day.
And finnally i found out about this.

It is because of my data migrated from magento V1 to magento V2.
Some categories have the same url as products. And when we save categories. It throws mysql exception named URL_REWRITE_REQUEST_PATH_STORE_ID (request_path, store_id is unique)

There are my solutions:
The firt one : Clean up your database in table url_rewrite (Change the url_key of all category). You can write UpgradeData script for this solution.

The second one : Remove the duplication data when saving 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);
    } 

After debugging, i found out $data variable have duplicate record. If you want this method to work without any errors. Rewrite this method above to:

protected function doReplace($urls)
    {
        foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData) {
            $urlData[UrlRewrite::ENTITY_TYPE] = $type;
            $this->deleteByData($urlData);
        }
        $data = [];
        $storeId_requestPaths = [];
        foreach ($urls as $url) {
            $storeId = $url->getStoreId();
            $requestPath = $url->getRequestPath();
            // Skip if is exist in the database
            $sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
            $exists = $this->connection->fetchOne($sql);

            if ($exists) continue;

            $storeId_requestPaths[] = $storeId . '-' . $requestPath;
            $data[] = $url->toArray();
        }

        // Remove duplication data;
        $n = count($storeId_requestPaths);
        for ($i = 0; $i < $n - 1; $i++) {
            for ($j = $i + 1; $j < $n; $j++) {
                if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j]) {
                    unset($data[$j]);
                }
            }
        }
        $this->insertMultiple($data);
    }

These solutions above both work for me. But the second one is not an ideal solution.
Because, there are wrong url_keys in your database.
And sometime, it will not work as you expected in the front end.

I hope it will help.
Thanks.
Toan Tam

@scher200
Copy link

scher200 commented Jul 26, 2017

@toanthree I like your second option, works great for me, I only added the last line of the old function, that makes it work for real:

    protected function doReplace($urls)
    {
        foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData) {
            $urlData[UrlRewrite::ENTITY_TYPE] = $type;
            $this->deleteByData($urlData);
        }
        $data = [];
        $storeId_requestPaths = [];
        foreach ($urls as $url) {
            $storeId = $url->getStoreId();
            $requestPath = $url->getRerquestPath();
            $url->setRequestPath($requestPath);

            // Skip if is exist in the database
            $sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
            $exists = $this->connection->fetchOne($sql);

            if ($exists) continue;

            $storeId_requestPaths[] = $storeId . '-' . $requestPath;
            $data[] = $url->toArray();
        }

        // Remove duplication data;
        $n = count($storeId_requestPaths);
        for ($i = 0; $i < $n - 1; $i++) {
            for ($j = $i + 1; $j < $n; $j++) {
                if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j]) {
                    unset($data[$j]);
                }
            }
        }

        // remove root links
        foreach( $data as $key => $info ){
            if(  isset($info['target_path']) && ( stristr($info['target_path'],'/category/1') || stristr($info['target_path'],'/category/2') ) && $info['entity_type']=='product' || $info['request_path'] == "" ){
                    unset($data[$key]);
            }
        }

        // create links
        if( count($data) > 0 ){
            // file_put_contents('var/log/url_rewite.log', print_r($data, TRUE), FILE_APPEND); // enable to log
            $this->insertMultiple($data);
        }

    }

@orlangur
Copy link
Contributor

orlangur commented Aug 2, 2017

@toanthree @scher200 guys, as far as I understood an implementation it is not a solution at all.

By skipping some request paths it simply makes products inaccessible in some stores using their url_key (so, URL Rewrite for such products will not be created and its URL in listing will be something like /catalog/product/view/id/123 instead of proper one).

Please tell me if my observation is wrong as I didn't try this code in action.

@m2-assistant
Copy link

m2-assistant bot commented Sep 20, 2019

Hi @VladimirZaets. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@VladimirZaets VladimirZaets removed their assignment Sep 20, 2019
@ghost ghost unassigned josefbehr Sep 27, 2019
@aliomattux
Copy link

aliomattux commented Oct 16, 2019

Magento Open Source 2.3.3
PHP 7.2.19
Ubuntu 18.04
Migrated database from 1.9.2.4

Steps to reproduce
Category has URL key of led-deck-lights
Product has URL key of aurora-odyssey-led-strip-light
There is also a URL rewrite with request path/target path
lighting/deck-stair-lights/aurora-odyssey-led-strip-light.html / aurora-odyssey-led-strip-light.html

Purpose of redirect is to redirect a direct category nested link to go directly to the product. Most likely for Canonical/SEO purposes.

When I go to the category in the admin, I can save the category changing some field values like name, etc. If I set Anchor Yes/No, just toggle the switch and save, I get an error that the URL key already exists. I receive the same error if I attempt to remove the single product from the category or if I go to the product and remove the category there, the same exact error.

This product does NOT have a duplicate key. The issue has been narrowed to a URL rewrite. Deleting the URL rewrite fixes the issue, however that is not a workable solution. The company has thousands of URL redirects for varying purposes. URL rewrite management is a valid business function. The raise exception is not logical based on the use case. The raise happens in module-url-rewrite/Model/Storage/DbStorage.php, doReplace()

There are many categories that have this issue and the only solution so far is to delete all url rewrites and not create them, which again is not an acceptable solution.

I have read at least 2 bug reports on this specific issue dating back to 2016. I do not understand why it is still an issue and is not fixed.

@aliomattux
Copy link

aliomattux commented Oct 16, 2019

I am not sure about all cases but I have determined the cause in our case and it is not necessarily a migration issue.
The business has categories and subcategories. They do not display products under all categories, they use a tile like configuration where a customer will drill down into categories, and eventually a product grid will be shown.

For some odd reason, the business created manual redirects from some of the full category paths to the product page directly, probably for some seo reason.
Example
Direct product url site.com/product.html
category url site.com/category/othercategory/product.html
manual redirect from site.com/category/othercategory/product.html to site.com/product.html

***I suspect that in Magento 2, a new functionality has been made to automatically create a url rewrite from site.com/category/othercategory/product.html to catalog/product/view/id/7550/category/90 - a new type of route
When a product is saved, the error is thrown because there is already a redirect for that request URL. The solution is to remove all such manual redirects - but I still question if this is an actual bug or a data problem and user error. I have pains with Magento design for url rewrite anyway, and often I see companies having to create manual nginx/apache rules because Magento doesn't support standard use cases.

@josefbehr
Copy link
Contributor

@aliomattux Thank you for the infos! I will try to have a look at this and talk to core developers at tomorrow's contribution day at MagentoLive Europe. Hopefully, we can find a solution.

@engcom-Bravo engcom-Bravo self-assigned this Nov 6, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 6, 2019

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo
Copy link
Contributor

Hi there. Could anyone please give the exact Steps to Reproduce following which the issue is reproducible on the vanilla 2.3-develop instance. @aliomattux I tried to use the info You've shared and if I understand it right I can reproduce somehow a behavior that gives an error. But that error is "The value specified in the URL Key field would generate a URL that already exists..." and not the one this issue is about, i.e., "URL key for specified store already exists". Besides I'm not sure that behavior isn't an expected one. Though Your explanations are very detailed, probably I still miss or misunderstand something. So could You please write more strict Steps to Reproduce something like this:

  1. Create an (Non-)Anchor category "First" with url-key "first".
  2. Create a (Non-)Anchor child category for First and name it "Second", url-key - "second".
    .............
    m) Create product "Prod" with url-key "prod" and assign it to category(ies) First, ...
    ............
    n) Manually create Url Rewrite with Request Path - "...." and Target Path - "...."
    ...........
    etc.
    Thank You.

@engcom-Charlie
Copy link
Contributor

We are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@taoufiqaitali
Copy link
Member

still have this issue, this should not be closed

@daweedco
Copy link

still have the issue also , magento 2.3.3

@northdakota
Copy link

Still have an issue on 2.3.3

@manishgoswamig
Copy link

Still have an issue on 2.3.4

@c0h1b4
Copy link

c0h1b4 commented Aug 21, 2020

Got this issue today on 2.3.4

@WebKenth
Copy link

This might be relevant to this issue:

If you have a parent category with is_anchored = true and the product you are trying to remove from the parent exists on a child category this constraint will trigger.

I can't confirm if it exists in all cases, but we are using Elasticsearch which contains the catalog_category_product index and have a "Smart Category" module which handles catalog_category_product index on it's own and whenever a save happens it attempts to check up on url_rewrites. so in our case it might just be this module.

I can consistently make it work by attempting to remove the product from the parent category. however if i go to the child category and remove the product, the exception does not happen. afterwards i can then remove the product from the parent category

@MarDenDev
Copy link

Same issue on 2.3.4.

I'm using an external module for categories import and it triggers this error. I'm aware now that it's a Magento2 core issue.
It doesn't seem to be an issue related with products but exclusively with categories.

@hostep
Copy link
Contributor

hostep commented Aug 25, 2020

For people who keep running against this, first start by investigating if you don't have invalid url-related data in your catalog, you can use this module for that if you want to. Then try to fix that invalid data (which you sometimes need to do directly in the database since Magento doesn't have an UI for specific data like product or category url_path's for example).

If you are importing new products or categories, then make sure the url_key's for them won't cause conflicts with already existing categories/products in your shop or with other categories/products in your import data. Everything needs to be unique, otherwise you'll get into troubles!

Hope this helps somehow 🙂

@manishgoswamig
Copy link

Magento Open Source 2.3.3
PHP 7.2.19
Ubuntu 18.04
Migrated database from 1.9.2.4

Steps to reproduce
Category has URL key of led-deck-lights
Product has URL key of aurora-odyssey-led-strip-light
There is also a URL rewrite with request path/target path
lighting/deck-stair-lights/aurora-odyssey-led-strip-light.html / aurora-odyssey-led-strip-light.html

Purpose of redirect is to redirect a direct category nested link to go directly to the product. Most likely for Canonical/SEO purposes.

When I go to the category in the admin, I can save the category changing some field values like name, etc. If I set Anchor Yes/No, just toggle the switch and save, I get an error that the URL key already exists. I receive the same error if I attempt to remove the single product from the category or if I go to the product and remove the category there, the same exact error.

This product does NOT have a duplicate key. The issue has been narrowed to a URL rewrite. Deleting the URL rewrite fixes the issue, however that is not a workable solution. The company has thousands of URL redirects for varying purposes. URL rewrite management is a valid business function. The raise exception is not logical based on the use case. The raise happens in module-url-rewrite/Model/Storage/DbStorage.php, doReplace()

There are many categories that have this issue and the only solution so far is to delete all url rewrites and not create them, which again is not an acceptable solution.

I have read at least 2 bug reports on this specific issue dating back to 2016. I do not understand why it is still an issue and is not fixed.

I am also facing this issue unable to understand why this is being happened.

@aliomattux
Copy link

I haven't been following this for a while but did have a quick update. Using Magento 2.3.3
I noticed some strange behavior today. This issue came up again with a product that could not be removed from a category. It listed 8 urls as offending. The product record did not have the url key mentioned, however when I queried the database it had the entry for attribute id = 72 which for me is url path. I also found a disabled product that had the same url key. The disabled product was the one that had the offending 8 urls. It seems that perhaps the url was changed at some point on the active product and only url key was updated, not url path. In the backend/admin it showed url key, but it appears that urls are dynamically generated using url path, not url key. I fixed the issue by changing url path in the database. Unsure if this was caused by a migration issue, or if in the admin there is a problem where saving/updating the url only updates one of the attributes and not the other. But truly, and annoying, agonizing, and frustrating issue.

@hostep
Copy link
Contributor

hostep commented Oct 2, 2020

@aliomattux: in fact you should clear the url_path for all products in your database. It's a legacy field from Magento 1 which for some reason is still included and being used by Magento 2, even though Magento 2 will never change its contents. It should therefore always be empty otherwise you'll run into problems. One of the reasons why it often isn't empty, is because people migrate from M1 to M2 and inadvertently copy the field over.

@JonathanHelvey
Copy link

I am running into this issues on Magento2.3.5pt-2. Is there any fix for this?

@WebKenth
Copy link

I am running into this issues on Magento2.3.5pt-2. Is there any fix for this?

You can install: https://github.com/baldwin-agency/magento2-module-url-data-integrity-checker to find possible bad categories and products

if you follow the url_path regeneration feature of magento2 within category save you can see that the problem exists internaly
The error happens when you attempt to save the category and it regenerates neighbouring category url_path's along with each category's products. if two products have the same url_key they conflict within the category and causes your category save to fail :s

@JonathanHelvey
Copy link

@WebKenth Thank you. I will give this a try. I know this module only shows you the problems. Does not fix. If I do find two products that have same url_key do I just manually delete url_key from Magento admin in url rewrites? Or do it from database? What would be the proper way to fix these conflicts?

@WebKenth
Copy link

@JonathanHelvey Yep or just change the product's url_key to something different

I handled it by updating the products url_key with a script that simply adds a number depending on the occurences :P

it can probably be done in multiple ways

@JonathanHelvey
Copy link

@WebKenth, Sounds good thank you for the advice. I guess, I could also go with a paid module that will do it for me. But like the free module says. It can mess with SEO. The paid module is pretty cheap from Magento store. https://marketplace.magento.com/webpanda-catalog-url-rewrites.html.

May do this to save time. If your url_key script is an open source project and up on github I would not mind trying your script out as well? If you are willing to share. Otherwise I will do it manually or start writing something out. Thanks for all the help.

@ecling
Copy link

ecling commented Aug 6, 2021

The request_path exceeds 255 and is truncated. If your mysql version is greater than 5.6,You can set the length to be greater than 255

@atma2021
Copy link

Anyone getting this error on M2.4.7-p1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: UrlRewrite Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests