开发者

Magento Extending Mage_Catalog_Block_Layer_Filter_Abstract

I have been trying for days to extend the abstract class

Mage_Catalog_Block_Layer_Filter_Abstract
开发者_StackOverflow中文版

I have tried the ways I have successfully extended non-abstract classes, with no luck. I need to do this because I have modified the filter.phtml file and this is where the template is set. So i basically just need a way to change the following function, without modifying any core files so it will be compatible when we update:

public function __construct()
{
    parent::__construct();
    $this->setTemplate('catalog/layer/filter.phtml');
}

I do not want to just modify the core template, because this will get erased when we update. Any help or any other ideas on how to do this would be greatly appreciated. I usually just edit the XML files, but this template is not called in an XML file and this is the only place I have found reference to it.

Thanks in advance!


For this we need to use setPageSize function.

Mage_Catalog_Block_Layer_Filter_Abstract class is responsible for setting filter template

You will override this Block class with your module’s class YourNamespace_YourModule_Block_Layer_Filter_Abstract. So, the path of class YourNamespace_YourModule_Block_Layer_Filter_Abstract is YourNamespace/YourModule/Block/Layer/Filter/Abstract.php

So your New File - Abstract.php will be like

<?php
class YourNamespace_YourModule_Block_Layer_Filter_Abstract extends  Mage_Catalog_Block_Layer_Filter_Abstract
    {
        /**

         */

    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('YourFolder/catalog/layer/filter.phtml');
    }

    }

Here is the xml code which is to be written in etc/config.xml for your custom module.

<global>
    <blocks>
        <catalog>
            <rewrite>
                <layer_filter_abstract>YourNamespace_YourModule_Block_Layer_Filter_Abstract</layer_filter_abstract>
            </rewrite>
        </catalog>
    </blocks>
<global>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜