new way of handling category searches
This commit is contained in:
@@ -10,7 +10,7 @@ from django.utils import timezone
|
||||
|
||||
import requests
|
||||
|
||||
from products.models import Product
|
||||
from products.models import Product, CategoryTag
|
||||
from companies.models import Company
|
||||
from history.models import HistorySync
|
||||
from PIL import Image
|
||||
@@ -144,7 +144,15 @@ def ranked_product_search(keyword, shipping_cost=None, discount=None, categories
|
||||
|
||||
# filter by category
|
||||
if categories is not None:
|
||||
products_qs = products_qs.filter(category__name__in=categories)
|
||||
# products_qs = products_qs.filter(category__name__in=categories)
|
||||
descendants = []
|
||||
for entry in categories:
|
||||
cat = CategoryTag.objects.filter(label__iexact=entry).first()
|
||||
# append category tag, and children
|
||||
descendants.append(cat)
|
||||
descendants.extend(cat.children.all())
|
||||
|
||||
products_qs = products_qs.filter(category__in=descendants)
|
||||
|
||||
# filter by tags
|
||||
if tags is not None:
|
||||
|
||||
Reference in New Issue
Block a user