feat: use ProductFiltersBuilder in all products page
This commit is contained in:
parent
7055969ef3
commit
565b178721
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user