You need to change reference block of product_type_data
- from:
product.info
- to:
product.info.options.wrapper
/ product_options_wrapper
Just like
<PRODUCT_TYPE_grouped translate="label" module="catalog">
<label>Catalog Product View (Grouped)</label>
<reference name="product_options_wrapper">
<!-- product.info to product_options_wrapper -->
The event you are observing (controller_action_layout_load_before
) is dispatched before layer filters are initialized. That's why you always get empty array when you call Mage::getSingleton('catalog/layer')->getState()->getFilters();
.
In fact, I think there is no suitable single event in Magento for what you're trying to do (add custom layout update handle and get all applied filters).
I would like to suggest an alternative approach but I don't know if it will suit you.
Add following layout update via local.xml
file:
<catalog_category_layered>
<reference name="content">
<block type="foo_bar/category" name="foo.bar.category.cmsblock" before="-"/>
</reference>
</catalog_category_layered>
And create a block which extends from Mage_Cms_Block_Block
class.
class Foo_Bar_Block_Category extends Mage_Cms_Block_Block
{
protected function _toHtml()
{
$filters = array();
$appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
foreach($appliedFilters as $filter) {
$filters[] = $filter->getFilter()->getRequestVar();
}
if (!empty($filters)) {
$this->setBlockId(implode('_', $filters));
}
return parent::_toHtml();
}
}
As you can see it's pretty simple. Line $this->setBlockId(implode('_', $filters));
sets the static block identifier and if the given block exists it will be loaded on your category pages.
Hope this helps.
Best Answer
To get
active filter
incatalog/layer/view.phtml
below code is working for me :