Magento 扩展 Mage_Catalog_Block_Layer_Filter_Abstract

发布于 2024-11-06 18:49:32 字数 473 浏览 1 评论 0原文

我已经尝试了几天来扩展抽象类,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

通知家属抬走 2024-11-13 18:49:32

为此,我们需要使用 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 将会像

<?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');
    }

    }

下面是要写入的 xml 代码etc/config.xml 用于您的自定义模块。

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文