fix: product query issues
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index f545b98..bff806d 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -77,10 +77,12 @@
search = frappe.form_dict.search
field_filters = frappe.parse_json(frappe.form_dict.field_filters)
attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters)
+ start = frappe.parse_json(frappe.form_dict.start)
else:
search = None
attribute_filters = None
field_filters = {}
+ start = 0
if not field_filters:
field_filters = {}
@@ -89,7 +91,7 @@
field_filters['item_group'] = self.name
engine = ProductQuery()
- context.items = engine.query(attribute_filters, field_filters, search)
+ context.items = engine.query(attribute_filters, field_filters, search, start)
filter_engine = ProductFiltersBuilder(self.name)
diff --git a/erpnext/shopping_cart/product_query.py b/erpnext/shopping_cart/product_query.py
index c5d3445..da9e798 100644
--- a/erpnext/shopping_cart/product_query.py
+++ b/erpnext/shopping_cart/product_query.py
@@ -2,6 +2,7 @@
# License: GNU General Public License v3. See license.txt
import frappe
+from erpnext.shopping_cart.product_info import get_product_info_for_website
class ProductQuery:
"""Query engine for product listing
@@ -21,7 +22,7 @@
self.settings = frappe.get_doc("Products Settings")
self.cart_settings = frappe.get_doc("Shopping Cart Settings")
self.page_length = self.settings.products_per_page or 20
- self.fields = ['name', 'item_name', 'website_image', 'variant_of', 'has_variants', 'item_group', 'image', 'web_long_description', 'description', 'route']
+ self.fields = ['name', 'item_name', 'item_code', 'website_image', 'variant_of', 'has_variants', 'item_group', 'image', 'web_long_description', 'description', 'route']
self.filters = [['show_in_website', '=', 1]]
self.or_filters = []
@@ -57,6 +58,8 @@
["Item Variant Attribute", "attribute_value", "in", values],
],
or_filters=self.or_filters,
+ start=start,
+ limit=self.page_length
)
items_dict = {item.name: item for item in items}
@@ -66,7 +69,11 @@
result = [items_dict.get(item) for item in list(set.intersection(*all_items))]
else:
- result = frappe.get_all("Item", fields=self.fields, filters=self.filters, or_filters=self.or_filters, limit=self.page_length)
+ result = frappe.get_all("Item", fields=self.fields, filters=self.filters, or_filters=self.or_filters, start=start, limit=self.page_length)
+
+ for item in result:
+ product_info = get_product_info_for_website(item.item_code, skip_quotation_creation=True).get('product_info')
+ item.formatted_price = product_info['price'].get('formatted_price') if product_info['price'] else None
return result
diff --git a/erpnext/www/all-products/index.py b/erpnext/www/all-products/index.py
index 2d4a357..2271b4c 100644
--- a/erpnext/www/all-products/index.py
+++ b/erpnext/www/all-products/index.py
@@ -12,11 +12,13 @@
search = frappe.form_dict.search
field_filters = frappe.parse_json(frappe.form_dict.field_filters)
attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters)
+ start = frappe.parse_json(frappe.form_dict.start)
else:
search = field_filters = attribute_filters = None
+ start = 0
engine = ProductQuery()
- context.items = engine.query(attribute_filters, field_filters, search)
+ context.items = engine.query(attribute_filters, field_filters, search, start)
product_settings = get_product_settings()
filter_engine = ProductFiltersBuilder()