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

# Conflicts:
#	erpnext/www/shop-by-category/index.py
  • Loading branch information
ssiyad authored and mergify[bot] committed Feb 12, 2023
1 parent f641039 commit de87786
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions erpnext/www/shop-by-category/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def get_tabs(categories):
return tab_values


def get_category_records(categories):
def get_category_records(categories: list):
categorical_data = {}
<<<<<<< HEAD
for category in categories:
if category == "item_group":
categorical_data["item_group"] = frappe.db.sql(
Expand All @@ -66,13 +67,28 @@ def get_category_records(categories):
and show_in_website = 1
""",
as_dict=1,
=======

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"],
>>>>>>> 0df28c7174 (fix(ecommerce): throw invalid doctype error in shop by category (#33901))
)
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"]

<<<<<<< HEAD
categorical_data[category] = frappe.db.sql(
f"""
Select
Expand All @@ -82,5 +98,12 @@ def get_category_records(categories):
""",
as_dict=1,
)
=======
data = frappe.db.get_all(doctype, fields=fields)
categorical_data[c] = data
except BaseException:
frappe.throw(_("DocType {} not found").format(doctype))
continue
>>>>>>> 0df28c7174 (fix(ecommerce): throw invalid doctype error in shop by category (#33901))

return categorical_data

0 comments on commit de87786

Please sign in to comment.