fix(ecommerce): throw invalid doctype error in shop by category (#33901)
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
parent
201573ab9a
commit
0df28c7174
@ -51,21 +51,31 @@ def get_tabs(categories):
|
|||||||
return tab_values
|
return tab_values
|
||||||
|
|
||||||
|
|
||||||
def get_category_records(categories):
|
def get_category_records(categories: list):
|
||||||
categorical_data = {}
|
categorical_data = {}
|
||||||
for category in categories:
|
|
||||||
if category == "item_group":
|
for c in categories:
|
||||||
|
if c == "item_group":
|
||||||
categorical_data["item_group"] = frappe.db.get_all(
|
categorical_data["item_group"] = frappe.db.get_all(
|
||||||
"Item Group",
|
"Item Group",
|
||||||
filters={"parent_item_group": "All Item Groups", "show_in_website": 1},
|
filters={"parent_item_group": "All Item Groups", "show_in_website": 1},
|
||||||
fields=["name", "parent_item_group", "is_group", "image", "route"],
|
fields=["name", "parent_item_group", "is_group", "image", "route"],
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
doctype = frappe.unscrub(category)
|
continue
|
||||||
fields = ["name"]
|
|
||||||
if frappe.get_meta(doctype, cached=True).get_field("image"):
|
doctype = frappe.unscrub(c)
|
||||||
|
fields = ["name"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
meta = frappe.get_meta(doctype, cached=True)
|
||||||
|
if meta.get_field("image"):
|
||||||
fields += ["image"]
|
fields += ["image"]
|
||||||
|
|
||||||
categorical_data[category] = frappe.db.get_all(doctype, fields=fields)
|
data = frappe.db.get_all(doctype, fields=fields)
|
||||||
|
categorical_data[c] = data
|
||||||
|
except BaseException:
|
||||||
|
frappe.throw(_("DocType {} not found").format(doctype))
|
||||||
|
continue
|
||||||
|
|
||||||
return categorical_data
|
return categorical_data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user