ThunderOver Posted March 10, 2023 Share Posted March 10, 2023 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 Link to comment Share on other sites More sharing options...
innovacy Posted March 17, 2023 Share Posted March 17, 2023 (edited) 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 March 17, 2023 by innovacy (see edit history) Link to comment Share on other sites More sharing options...
metacreo Posted March 17, 2023 Share Posted March 17, 2023 for ps 1.7.8.8 file /controllers/front/listing/SearchController.php protected function getProductSearchQuery() ->setSortOrder(new SortOrder('product', 'position', 'desc')) 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