|
@@ -1134,10 +1134,12 @@ class AbstractRange(models.Model):
|
1134
|
1134
|
self.included_categories.values("id")
|
1135
|
1135
|
)
|
1136
|
1136
|
_filter |= Q(categories__in=expanded_range_categories)
|
1137
|
|
- # extend filter for parent categories
|
1138
|
|
- if Product.objects.filter(
|
1139
|
|
- parent__categories__in=expanded_range_categories
|
1140
|
|
- ).exists():
|
|
1137
|
+ # extend filter for parent categories, exclude parent = None
|
|
1138
|
+ if (
|
|
1139
|
+ Product.objects.exclude(parent=None)
|
|
1140
|
+ .filter(parent__categories__in=expanded_range_categories)
|
|
1141
|
+ .exists()
|
|
1142
|
+ ):
|
1141
|
1143
|
_filter |= Q(parent__categories__in=expanded_range_categories)
|
1142
|
1144
|
|
1143
|
1145
|
qs = Product.objects.filter(_filter, ~Q(excludes=self))
|