Breadcrumbs management (#9544)

This commit is contained in:
Britlog 2017-07-10 08:44:05 +02:00 committed by Rushabh Mehta
parent 77aa4762b8
commit 8c85562ceb
2 changed files with 4 additions and 10 deletions

View File

@ -69,7 +69,7 @@ class ItemGroup(NestedSet, WebsiteGenerator):
context.update({
"items": get_product_list_for_group(product_group = self.name, start=start,
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,
"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):
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
and show_in_website=1
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)

View File

@ -146,10 +146,6 @@ class Item(WebsiteGenerator):
return cstr(frappe.db.get_value('Item Group', self.item_group,
'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):
"""Validate if the website image is a public file"""
auto_set_website_image = False
@ -242,15 +238,12 @@ class Item(WebsiteGenerator):
context.show_search=True
context.search_link = '/product_search'
context.parent_groups = get_parent_item_groups(self.item_group) + \
[{"name": self.name}]
context.parents = get_parent_item_groups(self.item_group)
self.set_variant_context(context)
self.set_attribute_context(context)
self.set_disabled_attributes(context)
self.get_parents(context)
return context
def set_variant_context(self, context):