0

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?

2 Answers 2

1

Check This one

  $filters = array();

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

  if (!empty($filters)) {
            //filter active
        }
        if (empty($filters)) {
            //no
        }
3
  • The response is null. The active filters is not detected. This code belongs to Observer.php. Commented Jan 19, 2016 at 13:05
  • @user2925795 please check this one magento.dingding.in/q/52992?lastactivity i think it will help you Commented Jan 19, 2016 at 13:10
  • This code doesnt work too. Could he be not identifying the rewrite as a filter? Commented Jan 20, 2016 at 11:27
1

You can check like below:

$layer = Mage::registry('current_layer');
if ($layer) {
    return $layer;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.