RobertNucci Posted September 30, 2016 Share Posted September 30, 2016 Hi, I would like to sort the products grid for "date added" in descending order, but I'd like to show on sale products last without taking care of the added date. I searched for a module or for the code to do that, and before developing a new one, I'm asking you if you know a solution to do so. Thank you very much, Robert Link to comment Share on other sites More sharing options...
shokinro Posted September 30, 2016 Share Posted September 30, 2016 you can check following files to override related code /classes/Category.php => getProducts() /classes/Product.php => getProducts() /classes/ProductSale.php => getBestSales() and getBestSalesLight() if you are using Block Layered Navigation module on product page, you will also need to look info following file, but it get product list inside the module, instead of calling above classes /module/blocklayered/blocklayered.php Link to comment Share on other sites More sharing options...
RobertNucci Posted September 30, 2016 Author Share Posted September 30, 2016 (edited) Hi shokinro, thank you for the answer. I know the code I should override, I was asking if someone has written it already instead of doing it myself. Anyway, I'm going to double the query: with the first I will put in the result array products not on sale; with the second I'll do that for the on sale products. So I'll return an array with all products displayed, but putting on sale products last. For the performance point of view that's not the best solution, but i should work. Robert UPDATE: I just figured out that I only need to add an order by for p.on_sale ASC. I'll try that! Edited September 30, 2016 by RobertNucci (see edit history) Link to comment Share on other sites More sharing options...
RobertNucci Posted September 30, 2016 Author Share Posted September 30, 2016 Hi ndiaga, I don't want to sort them by last product sold, but I need to show "on sale" products on the last page, so I can increase conversions on newer products. I'll try the orderby override and I'll let you know. Link to comment Share on other sites More sharing options...
shokinro Posted September 30, 2016 Share Posted September 30, 2016 yes you use "ORDER BY" statement in your sql, sort by sale date first and then sort by add date, that should work. 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