mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 20:59:11 +00:00
updates to product_page (search) and kb fix
This commit is contained in:
@@ -25,14 +25,6 @@ def get_product_info(item_code):
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 20,
|
||||
'search': '',
|
||||
'product_group': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
from webnotes.utils import cstr
|
||||
|
||||
@@ -40,11 +32,11 @@ def get_product_list(args=None):
|
||||
|
||||
# base query
|
||||
query = """\
|
||||
select name, item_name, page_name, website_image,
|
||||
description, web_short_description
|
||||
select name, item_name, page_name, website_image, item_group,
|
||||
if(ifnull(web_short_description,'')='', web_long_description,
|
||||
web_short_description) as web_short_description
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
where docstatus = 0
|
||||
and show_in_website = 1"""
|
||||
|
||||
# search term condition
|
||||
@@ -65,75 +57,6 @@ def get_product_list(args=None):
|
||||
and item_group = %(product_group)s"""
|
||||
|
||||
# order by
|
||||
query += """
|
||||
order by item_name asc, name asc"""
|
||||
query += """order by item_name asc, name asc limit %s, 10""" % args.start
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
return webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_category_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select count(name) as items, item_group
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
and show_in_website = 1
|
||||
group by item_group
|
||||
order by items desc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# add All Products link
|
||||
total_count = sum((r.get('items') or 0 for r in result))
|
||||
result = [{'items': total_count, 'item_group': 'All Products'}] + (result or [])
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_similar_product_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
'product_name': '',
|
||||
'product_group': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select name, item_name, page_name, website_image,
|
||||
description, web_short_description
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
and show_in_website = 1
|
||||
and name != %(product_name)s
|
||||
and item_group = %(product_group)s
|
||||
order by item_name"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
return result
|
||||
return webnotes.conn.sql(query, args, as_dict=1)
|
||||
Reference in New Issue
Block a user