[route] redesigned
This commit is contained in:
parent
cb067aa579
commit
ebd30beee4
@ -12,23 +12,28 @@ no_sitemap = 1
|
|||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_product_list(search=None, start=0, limit=10):
|
def get_product_list(search=None, start=0, limit=10):
|
||||||
# base query
|
# base query
|
||||||
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
|
query = """select name, item_name, page_name, website_image, item_group,
|
||||||
t1.web_long_description as website_description, t2.name as route
|
web_long_description as website_description, parent_website_route
|
||||||
from `tabItem` t1, `tabWebsite Route` t2 where t1.show_in_website = 1
|
from `tabItem` where show_in_website = 1"""
|
||||||
and t1.name = t2.docname and t2.ref_doctype = 'Item'"""
|
|
||||||
|
|
||||||
# search term condition
|
# search term condition
|
||||||
if search:
|
if search:
|
||||||
query += """and (t1.web_long_description like %(search)s or t1.description like %(search)s or
|
query += """and web_long_description like %(search)s
|
||||||
t1.item_name like %(search)s or t1.name like %(search)s)"""
|
or description like %(search)s
|
||||||
|
or item_name like %(search)s
|
||||||
|
or name like %(search)s)"""
|
||||||
search = "%" + cstr(search) + "%"
|
search = "%" + cstr(search) + "%"
|
||||||
|
|
||||||
# order by
|
# order by
|
||||||
query += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
|
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
|
||||||
|
|
||||||
data = frappe.db.sql(query, {
|
data = frappe.db.sql(query, {
|
||||||
"search": search,
|
"search": search,
|
||||||
}, as_dict=1)
|
}, as_dict=1)
|
||||||
|
|
||||||
|
for d in data:
|
||||||
|
d.route = ((d.parent_website_route + "/") if d.parent_website_route else "") \
|
||||||
|
+ d.page_name
|
||||||
|
|
||||||
return [get_item_for_list_in_html(r) for r in data]
|
return [get_item_for_list_in_html(r) for r in data]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user