Skip to content

Commit

Permalink
fix(ecommerce): throw invalid doctype error in shop by category (#33901)
Browse files Browse the repository at this point in the history
fix(ecommerce): throw invalid doctype error in shop by category (#33901)

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
(cherry picked from commit 0df28c7)

Co-authored-by: Sabu Siyad <hello@ssiyad.com>
  • Loading branch information
mergify[bot] and ssiyad authored Feb 12, 2023
1 parent 49fd712 commit 1d0e71b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions erpnext/www/shop-by-category/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1d0e71b

Please sign in to comment.