I have enabled "Use Categories Path for Product URLs". Because of this, I get category path in product url. But when we search the product, it redirect to the product url that does not contain category path.

I want same url always whether from catalog page or from search.

Please tell me how to achieve this. I am going to have single category for single product always.

Thanks !

  • 2
    imagine that one product is related to 2 or more categories. Which one should be included in URL when user use search? – Konrad Siamro Dec 14 '17 at 10:26
  • Any one of the category should be picked up. My aim is to have just one url for each products. Url must consists of one of the categories it belongs. – Pooja Mistry Dec 15 '17 at 3:41
  • Please help. I have not found solution yet. – Pooja Mistry Dec 17 '17 at 16:19

As you stated that you will always have product in unique category. Then disable the 'Use Categories Path for product Urls' then perform the reindex. Now you will have the same product url.

|improve this answer|||||
  • Yes I will always have product in unique category but I want Category path in product Urls for better seo. – Pooja Mistry Dec 23 '17 at 12:59
  • Then you have to overwrite the getUrl(){} function in file Magento\Catalog\Model\Product\Url. Here you can change the $requestPath = $product->getRequestPath(); If this path have category path included in it then you need not modify it. But if you have not category path in the requested path then you can append in it. Then all your product url will be with the category path at every page. – Ankur Verma Dec 27 '17 at 4:55

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.