{% extends 'oscar/search/results.html' %}
{% load i18n %}
{% load currency_filters thumbnail product_tags %}

{% block content %}
    <form method="get" class="form-horizontal">
        {# Render other search params as hidden inputs #}
        {% for value in search_form.selected_facets %}
            <input type="hidden" name="selected_facets" value="{{ value }}" />
        {% endfor %}
        <input type="hidden" name="q" value="{{ search_form.q.value }}" />

        {% if paginator.count %}
            {% if paginator.num_pages > 1 %}
                {% blocktrans with start=page_obj.start_index end=page_obj.end_index num_results=paginator.count %}
                    Found <strong>{{ num_results }}</strong> results, showing <strong>{{ start }}</strong> to <strong>{{ end }}</strong>.
                {% endblocktrans %}
            {% else %}
                {% blocktrans count num_results=paginator.count %}
                    Found <strong>{{ num_results }}</strong> result.
                {% plural %}
                    Found <strong>{{ num_results }}</strong> results.
                {% endblocktrans %}
            {% endif %}
            <div class="pull-right">
                {% include "oscar/partials/form_field.html" with field=search_form.sort_by %}
            </div>
        {% else %}
            <p>
                {% trans "Found <strong>0</strong> results." %}
                {% if suggestion %}
                    {% url 'search:search' as search_url %}
                    {% blocktrans %}
                        Did you mean <a href="{{ search_url }}?q={{ suggestion }}">"{{ suggestion }}"</a>?
                    {% endblocktrans %}
                {% endif %}
            </p>
        {% endif %}
    </form>
    {% block searchheading %}{% endblock %}

    {% if page_obj.object_list %}
        <section>
            <div>
                <ol class="row">
                    {% for result in page_obj.object_list %}
                        <li class="col-xs-6 col-sm-4 col-md-3 col-lg-3">{% render_product result %}</li>
                    {% endfor %}
                </ol>
                {% include "oscar/partials/pagination.html" with page_obj=page_obj %}
            </div>
        </section>
    {% endif %}

{% endblock %}

{% block column_left %}
    {% if has_facets %}
       <h4>{% trans "Refine by" %}
            <span class="icon-angle-down pull-right" data-toggle="collapse" data-target="#categories"></span>
        </h4>
        <div class="side_categories">
            {% for field, data in facet_data.items %}
                {% if data.results %}
                    {% include 'oscar/search/partials/facet.html' with name=data.name items=data.results %}
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
{% endblock %}
