Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Show in Website filters not working properly for Shop by Category (backport #118) #119

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Show in Website filters not working properly for Shop by Category (
#118)

(cherry picked from commit e942ae0)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Apr 16, 2024
commit e605ec03dd5c0088a95eb620fcfb44b552217bf6
18 changes: 15 additions & 3 deletions webshop/www/shop-by-category/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,31 @@ def get_tabs(categories):

def get_category_records(categories):
categorical_data = {}

for category in categories:
if category == "item_group":
categorical_data["item_group"] = frappe.db.get_all(
"Item Group",
filters={"parent_item_group": "All Item Groups", "show_in_website": 1},
filters={"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"):
meta = frappe.get_meta(doctype, cached=True)
if meta.get_field("image"):
fields += ["image"]

categorical_data[category] = frappe.db.get_all(doctype, fields=fields)
filters = {}
if meta.get_field("show_in_website"):
filters = {"show_in_website": 1}

elif meta.get_field("custom_show_in_website"):
filters = {"custom_show_in_website": 1}

if filters:
categorical_data[category] = frappe.db.get_all(doctype, fields=fields, filters=filters)
else:
categorical_data[category] = frappe.db.get_all(doctype, fields=fields)

return categorical_data
Loading