Magento Get Selected Filter In Layered Navigation

Viewed 30213

In Magento, if "color" attribute is chosen in layered navigation, values of the "color" are automatically disappears and results are getting displayed.How to retrieve the name of the selected filter?

3 Answers

You can get filter's attribute code or id through this code:

$appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
foreach ($appliedFilters as $item) {
    echo $item->getFilter()->getAttributeModel()->getAttributeId();
    echo $item->getFilter()->getAttributeModel()->getAttributeCode();
}

In Magento 2: $this->getLayer()->getState()->getData("filters")

Related