Magento – Check if Layered navigation filter is active on Magento

catalogfilterlayered-navigation

I'm having trouble identifying the catalog pages that are in active filters in Magento. I use a rewrite for URLs, are my filters as follows:

http://store.com/brand/foobrand/type/luxe/class/standard

In the Catalog page, I need to know is that the filter page is active or not.

Wherever I looked I thought almost always the same, but could not make it work:

$filters = array();
            $appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();

            foreach($appliedFilters as $filter) {
                $filters[] = $filter->getFilter()->getRequestVar();
            }

            if (!empty($filters)) {
                //filter active
            }
            if (empty($filters)) {
                //no
            }

Can anyone help me identify where you may be experiencing the problem?

Best Answer

Check This one

  $filters = array();

  $filters = Mage::getSingleton('Mage_Catalog_Block_Layer_State')->getActiveFilters();

  if (!empty($filters)) {
            //filter active
        }
        if (empty($filters)) {
            //no
        }