I have to implement the following scenario.
The default sort order in category (by position) should ignore the position set for the products in the category.
Instead when sorting by position it should follow this rule:
- Products added in the last X days at the top (X is configurable).
- Products that have a discount (special price or catalog rule) at the bottom.
- Rest of the products in between the 2 cases above.
My approach is to rewrite
Mage_Catalog_Model_Resource_Product_Collection::addAttributeToSort(). If the attribute code passed to it is
position I should execute my custom code. Otherwise
But what should my custom code be?
All products are simple or configurable.
Running a cron that updates the positions from time to time based on my rules is not a valid option in this case.