fix(ecommerce): throw invalid doctype error in shop by category (#33901)

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
Sabu Siyad 2023-02-11 12:28:42 +05:30 committed by GitHub
parent 201573ab9a
commit 0df28c7174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,21 +51,31 @@ def get_tabs(categories):
return tab_values
def get_category_records(categories):
def get_category_records(categories: list):
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(
"Item Group",
filters={"parent_item_group": "All Item Groups", "show_in_website": 1},
fields=["name", "parent_item_group", "is_group", "image", "route"],
)
else:
doctype = frappe.unscrub(category)
fields = ["name"]
if frappe.get_meta(doctype, cached=True).get_field("image"):
continue
doctype = frappe.unscrub(c)
fields = ["name"]
try:
meta = frappe.get_meta(doctype, cached=True)
if meta.get_field("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