added search filter by min and max price
This commit is contained in:
@@ -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, category=None, tags=None):
|
||||
def find_related_products_v6(keyword, shipping_cost=None, discount=None, category=None, tags=None, price_min=None,price_max=None):
|
||||
"""
|
||||
Ranked product search
|
||||
|
||||
@@ -151,7 +151,7 @@ def find_related_products_v6(keyword, shipping_cost=None, discount=None, categor
|
||||
if tags is not None:
|
||||
products_qs = products_qs.filter(tags=tags)
|
||||
|
||||
# filter for shipping cost
|
||||
# filter by shipping cost
|
||||
if shipping_cost is True:
|
||||
# only instances with shipping costs
|
||||
products_qs = products_qs.filter(
|
||||
@@ -162,7 +162,7 @@ def find_related_products_v6(keyword, shipping_cost=None, discount=None, categor
|
||||
# only intances without shpping costs
|
||||
products_qs = products_qs.filter(Q(shipping_cost=None)|Q(shipping_cost=0.00))
|
||||
|
||||
# filter for discount
|
||||
# filter by discount
|
||||
if discount is True:
|
||||
# only instances with shipping costs
|
||||
products_qs = products_qs.filter(
|
||||
@@ -173,6 +173,12 @@ def find_related_products_v6(keyword, shipping_cost=None, discount=None, categor
|
||||
# only intances without shpping costs
|
||||
products_qs = products_qs.filter(Q(discount=None)|Q(discount=0.00))
|
||||
|
||||
# filter by price
|
||||
if price_min is not None:
|
||||
products_qs = products_qs.filter(price__gt=price_min)
|
||||
if price_max is not None:
|
||||
products_qs = products_qs.filter(price__lt=price_max)
|
||||
|
||||
return set(products_qs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user