2

I want to return all active filters in a custom View Block in module catalog. While the categories are returned in the layered navigation view, this always returns an empty result:

class CategoryView extends \Magento\Catalog\Block\Category\View
{

    protected function _prepareLayout()
    {
        parent::_prepareLayout();

        // Doesn't work, filters are always empty
        $state = $this->_catalogLayer->getState();
        print_r($state->getFilters());

        return $this;
    }

}

Do I have to call some function first to trigger loading the filters?

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.