mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
Breadcrumbs management (#9544)
This commit is contained in:
@@ -69,7 +69,7 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
context.update({
|
context.update({
|
||||||
"items": get_product_list_for_group(product_group = self.name, start=start,
|
"items": get_product_list_for_group(product_group = self.name, start=start,
|
||||||
limit=context.page_length + 1, search=frappe.form_dict.get("search")),
|
limit=context.page_length + 1, search=frappe.form_dict.get("search")),
|
||||||
"parent_groups": get_parent_item_groups(self.name),
|
"parents": get_parent_item_groups(self.parent_item_group),
|
||||||
"title": self.name,
|
"title": self.name,
|
||||||
"products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list'))
|
"products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list'))
|
||||||
})
|
})
|
||||||
@@ -136,7 +136,8 @@ def get_group_item_count(item_group):
|
|||||||
|
|
||||||
def get_parent_item_groups(item_group_name):
|
def get_parent_item_groups(item_group_name):
|
||||||
item_group = frappe.get_doc("Item Group", item_group_name)
|
item_group = frappe.get_doc("Item Group", item_group_name)
|
||||||
return frappe.db.sql("""select name, route from `tabItem Group`
|
return [{"name": frappe._("Home"),"route":"/"}]+\
|
||||||
|
frappe.db.sql("""select name, route from `tabItem Group`
|
||||||
where lft <= %s and rgt >= %s
|
where lft <= %s and rgt >= %s
|
||||||
and show_in_website=1
|
and show_in_website=1
|
||||||
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
|
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
|
||||||
|
|||||||
@@ -146,10 +146,6 @@ class Item(WebsiteGenerator):
|
|||||||
return cstr(frappe.db.get_value('Item Group', self.item_group,
|
return cstr(frappe.db.get_value('Item Group', self.item_group,
|
||||||
'route')) + '/' + self.scrub(self.item_name + '-' + random_string(5))
|
'route')) + '/' + self.scrub(self.item_name + '-' + random_string(5))
|
||||||
|
|
||||||
def get_parents(self, context):
|
|
||||||
item_group, route = frappe.db.get_value('Item Group', self.item_group, ['name', 'route'])
|
|
||||||
context.parents = [{'name': route, 'label': item_group}]
|
|
||||||
|
|
||||||
def validate_website_image(self):
|
def validate_website_image(self):
|
||||||
"""Validate if the website image is a public file"""
|
"""Validate if the website image is a public file"""
|
||||||
auto_set_website_image = False
|
auto_set_website_image = False
|
||||||
@@ -242,15 +238,12 @@ class Item(WebsiteGenerator):
|
|||||||
context.show_search=True
|
context.show_search=True
|
||||||
context.search_link = '/product_search'
|
context.search_link = '/product_search'
|
||||||
|
|
||||||
context.parent_groups = get_parent_item_groups(self.item_group) + \
|
context.parents = get_parent_item_groups(self.item_group)
|
||||||
[{"name": self.name}]
|
|
||||||
|
|
||||||
self.set_variant_context(context)
|
self.set_variant_context(context)
|
||||||
self.set_attribute_context(context)
|
self.set_attribute_context(context)
|
||||||
self.set_disabled_attributes(context)
|
self.set_disabled_attributes(context)
|
||||||
|
|
||||||
self.get_parents(context)
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def set_variant_context(self, context):
|
def set_variant_context(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user