Jump to content

Sorting products for date added, but displaying on sale products last


RobertNucci

Recommended Posts

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

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

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 by RobertNucci (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...