Ejemplo n.º 1
0
def recommended_from_search(request):

    common_words = frequent_search_words(request)
    from spiritbuzz import search
    matching = []
    for word in common_words:
        results = search.products(word).get('products', [])
        for result in results:
            if len(matching) < 3 and not result in matching:
                matching.append(result)
    return matching
Ejemplo n.º 2
0
def results(request, template_name = "spiritbuzz/results.html"):

    categories = categoryList
    q = request.GET.get('q', '')

    try:
        page = int(request.GET.get('page', 1))
    except ValueError:
        page = 1

    matching = search.products(q).get('products')
    paginator = Paginator(matching, 9)

    try:
        results = paginator.page(page).object_list
    except (InvalidPage, EmptyPage):
        results = paginator.page(1).object_list

    search.store(request, q)
    page_title = 'Search Results for: '+ q

    return render_to_response(template_name, locals(), context_instance = RequestContext(request))