1

I searched for this kind of issue and saw many others experiencing this thing like me. I tried those fixes that they recommend but it's not working on my end.

Maybe you guys can suggest what is the best thing or any recommendations how to fix this one.

enter image description here

Any ideas on the best solution to fix this bug?

Thanks!

2 Answers 2

2

Truncating your url_rewrite table & run re-indexing.

It will create all url-key's automatically.

=> Note : Take backup of that table before truncate it.

For regenerate url :

Download this module and copy the Iazel directory into app/code/

Then you can regenerate SEO Friendly URL's for catalog/products via Console

# Regenerate url for all products and the global store
php bin/magento iazel:regenurl

# Regenerate url for products with id (1, 2, 3, 4) for store 1
php bin/magento iazel:regenurl -s1 1 2 3 4
10
  • Hmmm, I saw this method before. Thanks also I will try this one. May 30, 2018 at 4:45
  • Hello @Emipro Thanks, for now, this one solves my problem. May 30, 2018 at 5:35
  • Happy to help :) May 30, 2018 at 5:35
  • But there's a problem, I noticed the product's url changed to this kind of format: catalog/product/view/id/4513/s/test/ May 30, 2018 at 5:39
  • Any ideas about this one? May 30, 2018 at 5:40
0

That's known issue in Magento2.1.x

this issue is solved now magento2.2

you can check here for more detail

https://github.com/magento/magento2/issues/7298

for quick hack you can do following

Create a prefrence of this class vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php

and rewrite doReplace() this method

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);
}
1
  • I tried your method but unfortunately, it's not working on my end. Thanks anyway. May 30, 2018 at 5:23

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.