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? Commented Dec 14, 2017 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. Commented Dec 15, 2017 at 3:41
  • Please help. I have not found solution yet. Commented Dec 17, 2017 at 16:19

1 Answer 1


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.

  • Yes I will always have product in unique category but I want Category path in product Urls for better seo. Commented Dec 23, 2017 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. Commented Dec 27, 2017 at 4:55

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.