0

I've problem with products count in filters in layered navgiation. I've made filter for special price products, and it's works ok, products list is filtered. In filter applyToCollection I have

$collection->addAttributeToSelect('special_from_date')
->addAttributeToSelect('special_to_date')
->addAttributeToFilter('special_price', ['neq' => ''])
->addAttributeToFilter(
        'special_from_date',
        ['lteq' => date('Y-m-d H:i:s', strtotime($now))]
    )

 ->addAttributeToFilter(
        'special_to_date',
        ['gteq' => date('Y-m-d H:i:s', strtotime($now))]

);

But in filter (layered navigation) when I choose my filter, products counts in categories won't change they are the same as counts without filter. Also categories for products without special price don't disappear. Normally when you filter by attribute it causes the "empty" (not matching) categories (and attributes) are not displayed and counts are calculacted regarding to filter values. What I've to do to apply my custom filter to layered navigation, to hide unnecessary items and count products correctly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.