/** * Add layerd navigation filters on current layer block * * @param Mage_Catalog_Block_Layer_View $block * * @return $this */ protected function _addLayeredNavigation($block) { $stateBlock = $block->getLayout()->createBlock('catalog/layer_state')->setLayer($block->getLayer()); $block->setChild('layer_state', $stateBlock); $filterableAttributes = Mage::getResourceModel('factfinder_asn/product_attribute_collection'); foreach ($filterableAttributes as $index => $attribute) { $filter = $block->getLayout()->createBlock('factfinder_asn/catalog_layer_factfinder')->setAttributeModel($attribute)->setLayer($block->getLayer())->init(); $block->setChild($attribute->getAttributeCode() . '_filter', $filter); // remove category filter - it's enough to add it as a child if ($attribute->getAttributeCode() == 'category') { $filterableAttributes->removeItemByKey($index); } } $block->setData('_filterable_attributes', $filterableAttributes); return $this; }
/** * Remove the price filter options from the filterable attributes * * @param Mage_Catalog_Block_Layer_View $oBlock */ protected function removePriceFilter($oBlock) { $aFilterableAttributes = $oBlock->getData('_filterable_attributes'); $aNewFilterableAttributes = array(); foreach ($aFilterableAttributes as $oFilterableAttribute) { if ($oFilterableAttribute->getAttributeCode() != 'price') { $aNewFilterableAttributes[] = $oFilterableAttribute; } } $oBlock->setData('_filterable_attributes', $aNewFilterableAttributes); }
/** * Layered navigation block, clears on changed associated category ID * * @param Mage_Catalog_Block_Layer_View $block */ public function applyCatalogLayerView(Mage_Catalog_Block_Layer_View $block) { // Set cache tags $tags = $block->getLayer()->getStateTags(); $block->setData('cache_tags', $tags); $keys = $this->_getBasicKeys($block); $keys[] = $block->getLayer()->getStateKey(); foreach (Mage::app()->getRequest()->getParams() as $key => $value) { $value = Mage::helper('cache')->paramValueToCacheKey($value); $keys[] = $key . '_' . $value; } $block->setData('cache_key', $this->_getCacheKey($keys)); }