feat: use ProductFiltersBuilder in all products page

This commit is contained in:
Shivam Mishra 2020-12-29 17:18:58 +05:30
parent 7055969ef3
commit 565b178721

View File

@ -2,6 +2,7 @@ import frappe
from erpnext.portal.product_configurator.utils import (get_products_for_website, get_product_settings, from erpnext.portal.product_configurator.utils import (get_products_for_website, get_product_settings,
get_field_filter_data, get_attribute_filter_data) get_field_filter_data, get_attribute_filter_data)
from erpnext.shopping_cart.product_query import ProductQuery from erpnext.shopping_cart.product_query import ProductQuery
from erpnext.shopping_cart.filters import ProductFiltersBuilder
sitemap = 1 sitemap = 1
@ -14,21 +15,17 @@ def get_context(context):
else: else:
search = field_filters = attribute_filters = None search = field_filters = attribute_filters = None
# items = get_products_for_website(field_filters, attribute_filters, search)
engine = ProductQuery() engine = ProductQuery()
items = engine.query(attribute_filters, field_filters, search) context.items = engine.query(attribute_filters, field_filters, search)
product_settings = get_product_settings() product_settings = get_product_settings()
context.items = items filter_engine = ProductFiltersBuilder()
context.field_filters = get_field_filter_data() \
if product_settings.enable_field_filters else []
context.attribute_filters = get_attribute_filter_data() \ context.field_filters = filter_engine.get_field_filters()
if product_settings.enable_attribute_filters else [] context.attribute_filters = filter_engine.get_attribute_fitlers()
context.product_settings = product_settings context.product_settings = product_settings
context.body_class = "product-page" 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 context.no_cache = 1