simberak Posted September 15, 2016 Share Posted September 15, 2016 (edited) Hi all, when you search on the site, the products listed have added to the url "search_query=something" and "results=x". So it makes duplicate content of each searched product. For example if I search ESSW21 the link for chosen product is: www.domain.cz/ocelove-sperky-ocelove-nausnice/386-nausnice-essw21-cz-s-krystaly-swarovski-elements.html?search_query=essw21&results=7 But the original url is just: www.domain.cz/ocelove-sperky-ocelove-nausnice/386-nausnice-essw21-cz-s-krystaly-swarovski-elements.html So there are two urls with totaly same content... Unnecessarily... And at the product page accessed through search there is very ugly link pointing back to search which is useless also... How can I remove added parts from url while searching? Thank you for your kindly reply, Daniel Edited September 18, 2016 by simberak (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted September 18, 2016 Share Posted September 18, 2016 It's the following code on lines 100-104 (in PrestaShop v1.6.1.7) of controllers/front/SearchController.php that adds those parameters: if (is_array($search['result'])) { foreach ($search['result'] as &$product) { $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&').'search_query='.urlencode($query).'&results='.(int)$search['total']; } } You can override that function and remove that code. 1 Link to comment Share on other sites More sharing options...
simberak Posted September 18, 2016 Author Share Posted September 18, 2016 Super! I commented the code out and it is working! Thank you very much rocky 2 Link to comment Share on other sites More sharing options...
mir-aus Posted July 11, 2017 Share Posted July 11, 2017 Thanks for this information, it's working for me as well I did link this: /* foreach ($search['result'] as &$product) $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&').'search_query='.urlencode($query).'&results='.(int)$search['total']; */ Question is without this code what will happens ? Link to comment Share on other sites More sharing options...
Ben90 Posted July 12, 2017 Share Posted July 12, 2017 Any special reason why Prestashop is doing something like this in the search result? WooCommerce doesn't do something like this. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now