Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
Python
Raw Normal View History

import frappe
from erpnext.portal.product_configurator.utils import (get_products_for_website, get_product_settings,
get_field_filter_data, get_attribute_filter_data)
2020-12-24 17:54:07 +05:30
from erpnext.shopping_cart.product_query import ProductQuery
from erpnext.shopping_cart.filters import ProductFiltersBuilder
2019-03-20 14:11:22 +05:30
sitemap = 1
def get_context(context):
if frappe.form_dict:
search = frappe.form_dict.search
field_filters = frappe.parse_json(frappe.form_dict.field_filters)
attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters)
2021-01-20 17:44:08 +05:30
start = frappe.parse_json(frappe.form_dict.start)
else:
search = field_filters = attribute_filters = None
2021-01-20 17:44:08 +05:30
start = 0
2020-12-24 17:54:07 +05:30
engine = ProductQuery()
2021-01-20 17:44:08 +05:30
context.items = engine.query(attribute_filters, field_filters, search, start)
2020-12-22 12:44:09 +05:30
# Add homepage as parent
context.parents = [{"name": frappe._("Home"), "route":"/"}]
product_settings = get_product_settings()
filter_engine = ProductFiltersBuilder()
context.field_filters = filter_engine.get_field_filters()
context.attribute_filters = filter_engine.get_attribute_fitlers()
context.product_settings = product_settings
2020-12-24 17:54:07 +05:30
context.body_class = "product-page"
context.page_length = product_settings.products_per_page or 20
context.no_cache = 1