Closed baffolobill closed 10 years ago
Thanks for reporting this. I will look into it asap.
I think that best solution for this would be to add extra field to the Product model that will store 'current' price. It will be updated with pre_save signal on product depending on 'for sale' being enabled.
effective_price
is used for this, look at catalog/models.py
:
class Product(models.Model):
...
def save(self, *args, **kwargs):
"""
Overwritten to save effective_price.
"""
if self.for_sale:
self.effective_price = self.for_sale_price
else:
self.effective_price = self.price
super(Product, self).save(*args, **kwargs)
...
Look at the commit https://github.com/diefenbach/django-lfs/commit/67bab79c3d6353a5fd6e064399a4f9e90f0841f7, for example - everywhere is used price
as default value to sort.
Sorting by
price
doesn't take into account thefor_sale_price
field.