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 !
-
2imagine that one product is related to 2 or more categories. Which one should be included in URL when user use search?Konrad Siamro– Konrad Siamro2017年12月14日 10:26:45 +00:00Commented 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.Pooja Mistry– Pooja Mistry2017年12月15日 03:41:10 +00:00Commented Dec 15, 2017 at 3:41
-
Please help. I have not found solution yet.Pooja Mistry– Pooja Mistry2017年12月17日 16:19:58 +00:00Commented 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.Pooja Mistry– Pooja Mistry2017年12月23日 12:59:04 +00:00Commented 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.Ankur Verma– Ankur Verma2017年12月27日 04:55:28 +00:00Commented Dec 27, 2017 at 4:55
Explore related questions
See similar questions with these tags.