Jump to content

How to change the order of the products in the search page and in the ajax live search


ThunderOver

Recommended Posts

Hi, how to change the order of the products in the search page and in the ajax live search ?

I noticed that by default the search sorts the products by relevance

I have already changed the order in settings>products>paging but it only takes effect in the categories and not in the search page or in the ajax search results

 

 

1.png

Cattura.PNG

Link to comment
Share on other sites

To change the order of products in the search results page and the AJAX live search in PrestaShop, you will need to modify the core code to adjust the sorting behavior. Please note that modifying core files is not recommended, as it may cause issues during future updates.

However, if you still wish to proceed, in the PrestaShop core files, locate the file SearchController.php. This file is usually located in the /controllers/front/ folder. Locate the methods $query->orderBy(...) and variables called $orderBy and Tools::getProductsOrder(...) (for AJAX). Change to your hearts desire, however, using an override is suggested.

Please note, this is based on my memory and it may not be 100% accurate, however, in that case they should be named similar.

Edited by innovacy (see edit history)
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...