From 565b178721b290d6d18a845c05c214b59c0dfc2e Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 29 Dec 2020 17:18:58 +0530 Subject: [PATCH] feat: use ProductFiltersBuilder in all products page --- erpnext/www/all-products/index.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/erpnext/www/all-products/index.py b/erpnext/www/all-products/index.py index 6ebc1c305e..2d4a357e5e 100644 --- a/erpnext/www/all-products/index.py +++ b/erpnext/www/all-products/index.py @@ -2,6 +2,7 @@ import frappe from erpnext.portal.product_configurator.utils import (get_products_for_website, get_product_settings, get_field_filter_data, get_attribute_filter_data) from erpnext.shopping_cart.product_query import ProductQuery +from erpnext.shopping_cart.filters import ProductFiltersBuilder sitemap = 1 @@ -13,22 +14,18 @@ def get_context(context): attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters) else: search = field_filters = attribute_filters = None - - # items = get_products_for_website(field_filters, attribute_filters, search) - + engine = ProductQuery() - items = engine.query(attribute_filters, field_filters, search) + context.items = engine.query(attribute_filters, field_filters, search) product_settings = get_product_settings() - context.items = items - context.field_filters = get_field_filter_data() \ - if product_settings.enable_field_filters else [] + filter_engine = ProductFiltersBuilder() - context.attribute_filters = get_attribute_filter_data() \ - if product_settings.enable_attribute_filters else [] + context.field_filters = filter_engine.get_field_filters() + context.attribute_filters = filter_engine.get_attribute_fitlers() context.product_settings = product_settings context.body_class = "product-page" - context.page_length = product_settings.products_per_page + context.page_length = product_settings.products_per_page or 20 context.no_cache = 1