fix(ecommerce): throw invalid doctype error in shop by category (#33901)
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
(cherry picked from commit 0df28c7174)
# Conflicts:
# erpnext/www/shop-by-category/index.py
This commit is contained in:
@@ -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(
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user