brotherton-erpnext/erpnext/www/all-products/index.py

32 lines
1.0 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)
2019-03-20 08:41:22 +00:00
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)
else:
search = field_filters = attribute_filters = None
context.items = get_products_for_website(field_filters, attribute_filters, search)
2020-12-22 07:14:09 +00:00
# Add homepage as parent
context.parents = [{"name": frappe._("Home"), "route":"/"}]
product_settings = get_product_settings()
context.field_filters = get_field_filter_data() \
if product_settings.enable_field_filters else []
context.attribute_filters = get_attribute_filter_data() \
if product_settings.enable_attribute_filters else []
context.product_settings = product_settings
context.page_length = product_settings.products_per_page
context.no_cache = 1