Magento 扩展 Mage_Catalog_Block_Layer_Filter_Abstract
我已经尝试了几天来扩展抽象类,
Mage_Catalog_Block_Layer_Filter_Abstract
我尝试了成功扩展非抽象类的方法,但没有成功。我需要这样做,因为我已经修改了filter.phtml 文件,并且这是设置模板的位置。所以我基本上只需要一种方法来更改以下功能,而不修改任何核心文件,这样我们更新时它就会兼容:
public function __construct()
{
parent::__construct();
$this->setTemplate('catalog/layer/filter.phtml');
}
我不想只修改核心模板,因为当我们更新时它会被删除。任何有关如何执行此操作的帮助或任何其他想法将不胜感激。我通常只编辑 XML 文件,但该模板不会在 XML 文件中调用,这是我找到引用它的唯一地方。
提前致谢!
I have been trying for days to extend the abstract class
Mage_Catalog_Block_Layer_Filter_Abstract
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,我们需要使用 setPageSize 函数。
Mage_Catalog_Block_Layer_Filter_Abstract 类负责设置过滤器模板。
您将使用模块的类 YourNamespace_YourModule_Block_Layer_Filter_Abstract 覆盖此 Block 类。因此,类 YourNamespace_YourModule_Block_Layer_Filter_Abstract 的路径是 YourNamespace/YourModule/Block/Layer/Filter/Abstract.php
所以你的新文件 - Abstract.php 将会像
下面是要写入的 xml 代码etc/config.xml 用于您的自定义模块。
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
Here is the xml code which is to be written in etc/config.xml for your custom module.