4

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 !

Rakesh Jesadiya
42.5k19 gold badges135 silver badges186 bronze badges
asked Dec 14, 2017 at 10:23
3
  • 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

0

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.

answered Dec 21, 2017 at 16:26
2
  • 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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.