Jump to content

[SOLVED] URLs from list of products found by Search in FO


simberak

Recommended Posts

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 by simberak (see edit history)
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...