#88

Product support

Visit this product's website for support.

Categories

  • Marketing

The Filtering plugin adds functionality to Shopaholic plugin, allowing you to create filters by brand and properties, including the properties provided by the Properties for Shopaholic plugin (if it’s installed).

With this plugin you can:

  • Create complex filters and display them through interactive interface components (checkboxes and radio buttons, sliders).
  • Add customizable filters by price that allow users to choose products of a certain price range from a minimum to a maximum amount.
  • Add custom filters like “Discounted products” or “Products in stock” that check if the products have discounts or if they are currently in store.
  • Choose which properties are to be included in a filter and customize it according to your individual needs.

Get involved and contribute to the project

If you're interested in improving this project you can help in the following ways:

  • Reporting bugs and recommending new features on our plugin GitHub issues page; Contributing to the project following these instructions;

License

© 2017, LOVATA Group, LLC under GNU GPL v3.

Developed by Andrey Kharanenka.

These plugin(s) are required for the plugin:

Product properties for category

The full plugin documentation is abailable here.

Extension CategoryItem class

Filter for Shopaholic plugin adds fields to CategoryItem class object:

"product_filter_property" and "offer_filter_property" fields in CategoryItem object returns FilterPropertyCollection object with sorted active properties for this category. Property collection object has elements with properties, enabled how filters. "product_filter_property" and "offer_filter_property" fields helps render filter panel by properties of products or offers.

Example: render of filter panel for category

[CategoryPage]
slug = "{{ :slug }}"
==

{# Get category item #}
{% set obCategory = CategoryPage.get() %}
<div data-id="{{ obCategory.id }}">
    <h1>{{ obCategory.name }}</h1>
    {# Get products proeprty list for category, enabled how filters #}
    {% set obPropertyList = obCategory.product_filter_property %}
    {% if obPropertyList.isNotEmpty == true %}
        {% for obProeprty in obPropertyList if obProeprty.hasValue() %}

            {# Render filter name #}
            <div>{{ obPropertyList.getFilterName(obProeprty.id) }}</div>

            {# Get filter type #}
            {% set sFilterType = obPropertyList.getFilterType(obProeprty.id) %}

            {# Get proeprty value list #}
            {% set obPropertyValueList = obProeprty.property_value.sort().unique().notEmpty() %}

            {# Render filtre with type == checkbox #}
            {% if sFilterType == 'checkbox' %}
                {% for obValue in obPropertyValueList %}
                    <input type="checkbox" value="{{ obValue.slug }}">
                    <label>{{ obValue.value }}</label>
                {% endfor%}
            {% endif %}

            {# Render filtre with type == select #}
            {% if sFilterType == 'select' %}
                <select>
                    {% for obValue in obPropertyValueList %}
                        <option value="{{ obValue.slug }}">{{ obValue.value }}</option>
                    {% endfor%}
                </select>
            {% endif %}
        {% endfor %}
    {% endif %}
</div>

Extension ProductCollection class

Filter for Shopaholic plugin adds filtration methods to ProductCollection class:

filterByPrice($fStartPrice, $fStopPrice)

Method applies a filter by range of offer price from $fStartPrice to $fStopPrice. If $fStartPrice has empty value, then method applies a filter by range of offer price from 0 to $fStopPrice. If $fStopPrice has empty value, then method applies a filter by range of offer price from $fStartPrice. If $fStopPrice and $fStartPrice has empty value, then method isn't apply a filter by range of offer price.

    $obList = ProductCollection::make([1,2,10,15])->filterByPrice(10, 15);

filterByBrandList($arBrandIDList)

  • $arBrandIDList - array with brand ID's

Method applies a filter by list of brands.

    $obList = ProductCollection::make([1,2,10,15])->filterByBrandList([10, 15]);

filterByDiscount()

Method applies a filter and returns product list with offers that have a discount.

    $obList = ProductCollection::make([1,2,10,15])->filterByDiscount();

filterByQuantity()

Method applies a filter and returns product list with offers that have a quantity value > 0.

    $obList = ProductCollection::make([1,2,10,15])->filterByQuantity();

filterByProperty($arFilterList, $obPropertyList)

Method works only with Properties for Shopaholic plugin. Method applies a filter by product or offer properties.

You needs to prepare array $arFilterList in format:

    $arFilterList = [
        '12' => [ //Property ID
            'green', 'blue' //Array with values of properties for filtration
        ],
        15 => [
            10, 14 //Array with range of values (only for filter with type 'between')
        ],
    ];

You needs to get $obPropertyList object from current category item:

    //Apply filter by product properties
    $obCategory = CategoryItem.make(10);
    $obPropertyList = $obCategory.product_filter_property;

    $obList = ProductCollection::make([1,2,10,15])->filterByProperty($arFilterList, $obPropertyList);

    //.....

    //Apply filter by offer properties
    $obCategory = CategoryItem.make(10);
    $obPropertyList = $obCategory.offer_filter_property;

    $obList = ProductCollection::make([1,2,10,15])->filterByProperty($arFilterList, $obPropertyList);

Extension OfferCollection class

Filter for Shopaholic plugin adds filtration methods to OfferCollection class:

filterByPrice($fStartPrice, $fStopPrice)

Method applies a filter by range of price value from $fStartPrice to $fStopPrice. If $fStartPrice has empty value, then method applies a filter by range of price value from 0 to $fStopPrice. If $fStopPrice has empty value, then method applies a filter by range of price value from $fStartPrice. If $fStopPrice and $fStartPrice has empty value, then method isn't apply a filter by range of price value.

    $obList = OfferCollection::make([1,2,10,15])->filterByPrice(10, 15);

filterByProperty($arFilterList, $obPropertyList)

Method works only with Properties for Shopaholic plugin. Method applies a filter by offer properties.

You needs to prepare array $arFilterList in format:

    $arFilterList = [
        '12' => [ //Property ID
            'green', 'blue' //Array with values of properties for filtration
        ],
        15 => [
            10, 14 //Array with range of values (only for filter with type 'between')
        ],
    ];

You needs to get $obPropertyList object from current category item:

    $obCategory = CategoryItem.make(10);
    $obPropertyList = $obCategory.offer_filter_property;

    $obList = OfferCollection::make([1,2,10,15])->filterByProperty($arFilterList, $obPropertyList);
1.0.0

Initialize plugin.

Dec 06, 2017