fixing changes to product search
This commit is contained in:
@@ -124,7 +124,7 @@ def get_related_products(product):
|
||||
return total_results[:10]
|
||||
|
||||
|
||||
def ranked_product_search(keyword, shipping_cost=None, discount=None, category=None, tags=None, price_min=None,price_max=None):
|
||||
def ranked_product_search(keyword, shipping_cost=None, discount=None, categories=None, tags=None, price_min=None,price_max=None):
|
||||
"""
|
||||
Ranked product search
|
||||
|
||||
@@ -135,7 +135,7 @@ def ranked_product_search(keyword, shipping_cost=None, discount=None, category=N
|
||||
allow filtering by:
|
||||
- shipping cost
|
||||
"""
|
||||
vector = SearchVector('name') + SearchVector('description') + SearchVector('tags__label') + SearchVector('attributes__label') + SearchVector('category__label') + SearchVector('company__company_name')
|
||||
vector = SearchVector('name') + SearchVector('description') + SearchVector('tags__label') + SearchVector('attributes__label') + SearchVector('category__name') + SearchVector('company__company_name')
|
||||
query = SearchQuery(keyword)
|
||||
|
||||
products_qs = Product.objects.annotate(
|
||||
@@ -143,8 +143,8 @@ def ranked_product_search(keyword, shipping_cost=None, discount=None, category=N
|
||||
).filter(rank__gt=0.05, active=True)
|
||||
|
||||
# filter by category
|
||||
if category is not None:
|
||||
products_qs = products_qs.filter(category__name__in=category)
|
||||
if categories is not None:
|
||||
products_qs = products_qs.filter(category__name__in=categories)
|
||||
|
||||
# filter by tags
|
||||
if tags is not None:
|
||||
|
||||
Reference in New Issue
Block a user