1

I want to change my category display mode if there is active filters. My config.xml is :

    <events>
        <catalog_block_product_list_collection>
            <observers>
                <mycustom_module_observer>
                    <type>singleton</type>
                    <class>Mycustom_Module_Model_Observer</class>
                    <method>setCategoryDisplayMode</method>
                </mycustom_module_observer>
            </observers>
        </catalog_block_product_list_collection>
    </events>

And my observer is method is :

public function setCategoryDisplayMode(Varien_Event_Observer $observer)
{
    $category = Mage::registry('current_category');
    $appliedFilters = Mage::getSingleton('catalog/layer')
        ->getState()
        ->getFilters();
    if (!empty($appliedFilters)) {
        $category->setDisplayMode("PRODUCTS");
    }
}

But I am unable to get active filters with $appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters(); Is I am doing something wrong or my event is wrong?

I also tried with Mage::getSingleton('Mage_Catalog_Block_Layer_State')->getActiveFilters(); but no success.

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.