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?
All the applied filters are stored in layer state object. You can easily retrieve them by using the following snippet:
$appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
It will return you an array of filter item objects. You can retrieve name and applied value of a single filter item by doing something like this:
foreach ($appliedFilters as $item) {
$item->getName(); // Name of the filter
$item->getLabel(); // Currently selected value
$item->getFilter()->getRequestVar(); // Filter code (usually attribute code, except category filter, where it equals "cat")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With