Arnaud_R Posted July 19, 2021 Share Posted July 19, 2021 Hello, We are using Prestashop 1.6.1.10 and we currently face an issue that we are not able to solve. As you know it's possible to change the sorting by default in preference tab > products > sorting by default. We chose to sort by quantity in order to display first all products that we have in stock. When we take a loot at the product listing, it properly displays max quantity first, but after displaying all products that we have in several quantities then sorting by default is by product id. It's fine to have a 'second' sorting by product id, but we would like to use DESC sorting and not ASC sorting in order to display the newest products first. We checked a lot of php files but we don't find where this sorting by id/position is set. I guess we would only have to change ASC to DESC to have the expected behavior. I think it could benefit to a lot of merchants to know where the second sorting is configured, after the first sorting which is easy to change in the backoffice. Hope it was clear enough, thanks the community for your help ! :) Link to comment Share on other sites More sharing options...
musicmaster Posted July 21, 2021 Share Posted July 21, 2021 I haven't tested it but I would assume that the function assignProductList() in /controllers/front/CategoryController.php might a good place to do this. You would then add at the beginning a line like if($this->orderBy == 'id_product") $this->orderWay = "DESC"; 1 Link to comment Share on other sites More sharing options...
Arnaud_R Posted July 22, 2021 Author Share Posted July 22, 2021 Hello @musicmaster, Thanks for your help ! Just tested but unfortunately it doesn't change the sorting, do you have or somebody else another idea to solve this issue ? I guess this behavior is configured somewhere and we would just have to change ASC to DESC. Thanks a lot, Best Link to comment Share on other sites More sharing options...
musicmaster Posted July 22, 2021 Share Posted July 22, 2021 The search is done in the function getProducts() in classes/Category.php. You will need to experiment. Link to comment Share on other sites More sharing options...
StrefaBiznesu Posted August 1, 2022 Share Posted August 1, 2022 On 7/22/2021 at 3:43 PM, musicmaster said: The search is done in the function getProducts() in classes/Category.php. You will need to experiment. How to set it to sort by quantity 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