Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change filters order
michale9baa472124d
diff --git a/saleor/product/filters.py b/saleor/product/filters.pyindex 4f8253e3d2..29b0951b8e 100644--- a/saleor/product/filters.py+++ b/saleor/product/filters.py@@ -1,3 +1,5 @@+from collections import OrderedDict+from django_filters import FilterSet, MultipleChoiceFilter, RangeFilterfrom django.forms import CheckboxSelectMultiple@@ -32,6 +34,7 @@ class ProductFilter(FilterSet):label=attribute.name,widget=CheckboxSelectMultiple,choices=get_attribute_choices(attribute))+ self.filters = OrderedDict(sorted(self.filters.items()))class Meta:model = Productdiff --git a/saleor/product/views.py b/saleor/product/views.pyindex a5a8c22217..8248935118 100644--- a/saleor/product/views.py+++ b/saleor/product/views.py@@ -113,19 +113,13 @@ def product_add_to_cart(request, slug, product_id):def category_index(request, path, category_id):category = get_object_or_404(Category, id=category_id)actual_path = category.get_full_path()-- products = (Product.objects.filter(categories__name=category)- .prefetch_related(- 'images',- 'product_class__variant_attributes__values',- 'product_class__product_attributes__values',- 'variants__stock').all())-- product_filters = ProductFilter(request.GET, queryset=products)+ products = products_with_details(user=request.user)\+ .filter(categories__name=category)+ product_filter = ProductFilter(request.GET, queryset=products)if actual_path != path:return redirect('product:category', permanent=True, path=actual_path,category_id=category_id)return TemplateResponse(request, 'category/index.html',{'category': category,- 'filter': product_filters})+ 'filter': product_filter})