diff --git a/engine/core/models.py b/engine/core/models.py index 690f7014..3bcacd05 100644 --- a/engine/core/models.py +++ b/engine/core/models.py @@ -464,14 +464,18 @@ class Category(NiceModel, MPTTModel): @cached_property def min_price(self) -> float: return ( - self.products.filter(is_active=True).aggregate(Min("price"))["price__min"] + self.products.filter( + is_active=True, stocks__is_active=True + ).aggregate(Min("stocks__price"))["stocks__price__min"] or 0.0 ) @cached_property def max_price(self) -> float: return ( - self.products.filter(is_active=True).aggregate(Max("price"))["price__max"] + self.products.filter( + is_active=True, stocks__is_active=True + ).aggregate(Max("stocks__price"))["stocks__price__max"] or 0.0 )