I try to create module for custom filter.phtml, but rewriting doesn't work and it show default template for layered navigation options. I tried many ways but without success and now I have no idea why this thing doesn't work. Here is my code:














Block/Catalog/Layer/Filter/Abstract.php (I also had tried without "Catalog")

class My_Module_Block_Layer_Filter_Abstract extends Mage_Catalog_Block_Layer_Filter_Abstract {

public function __construct()


Maby somebody can help me?


You cannot rewrite an abstract class in Magento. You can only rewrite classes that you instantiate directly and since abstract class is never instantiated, it can never be rewritten.

The only way to override this specific class would be to copy it over to local code pool, following the same path structure, but I highly discourage this approach.

Much better option, in your case, would be to rewrite Mage_Catalog_Block_Layer_View class and modify it's _prepareLayout method. I've added comments in the code below.

protected function _prepareLayout()
    $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)

    $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)

    $this->setChild('layer_state', $stateBlock);
    $this->setChild('category_filter', $categoryBlock);

    $filterableAttributes = $this->_getFilterableAttributes();
    foreach ($filterableAttributes as $attribute) {
        if ($attribute->getAttributeCode() == 'price') {
            $filterBlockName = $this->_priceFilterBlockName;
        } elseif ($attribute->getBackendType() == 'decimal') {
            $filterBlockName = $this->_decimalFilterBlockName;
        } else {
            $filterBlockName = $this->_attributeFilterBlockName;

        // This is where one of the Mage_Catalog_Block_Layer_Filter_* classes
        // are instantiated. They all extend Mage_Catalog_Block_Layer_Filter_Abstract
        // which means that you can call setTemplate here and redefine one that is
        // set in abstract class. You can also set different templates based block type.

        $this->setChild($attribute->getAttributeCode() . '_filter',
                // Set your template here


    return $this;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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