enabled search by category

This commit is contained in:
Sam
2021-02-23 12:36:12 +00:00
parent cbfbfb93f3
commit 28d61c75c0
3 changed files with 44 additions and 25 deletions

View File

@@ -125,7 +125,7 @@ def find_related_products_v3(keyword):
return set(products_qs)
def find_related_products_v6(keyword, shipping_cost=None, discount=None):
def find_related_products_v6(keyword, shipping_cost=None, discount=None, category=None):
"""
Ranked product search
@@ -143,6 +143,10 @@ def find_related_products_v6(keyword, shipping_cost=None, discount=None):
rank=SearchRank(vector, query)
).filter(rank__gt=0.05) # removed order_by because its lost in casting
# filter by category
if category is not None:
products_qs = products_qs.filter(category=category)
# filter for shipping cost
if shipping_cost is True:
# only instances with shipping costs