无法覆盖 Magento 中的核心模型

发布于 2024-09-10 08:10:18 字数 1533 浏览 2 评论 0原文

我正在尝试覆盖 Mage_Catalog_Model_Layer_Filter_Category。 在 system.log 中我收到警告:

警告:包含(Mycomp_Catalog_Model_Layer_Filter_Category.php):无法打开流:第 93 行 /var/www/magento/includes/src/Varien_Autoload.php 中没有此类文件或目录 警告:include():无法在 /var 中打开“Mycomp_Catalog_Model_Layer_Filter_Category.php”以进行包含(include_path='/var/www/magento/includes/src:.:/usr/share/php:/usr/share/pear') /www/magento/includes/src/Varien_Autoload.php 第 93 行

我做错了什么?

Mycomp/Catalog/etc/config.xml:

<?xml version="1.0"?>
<config>
<modules>
    <Mycomp_Catalog>
        <version>0.1.0</version>
    </Mycomp_Catalog>
</modules>
<global>
    <models>
        <catalog>
            <rewrite>                    
                <layer_filter_category>Mycomp_Catalog_Model_Layer_Filter_Category</layer_filter_category>
            </rewrite>
        </catalog>
    </models>
</global>

Mycomp/Catalog/Model/Layer/Filter/Category.php:

class Mycomp_Catalog_Model_Layer_Filter_Category extends  Mage_Catalog_Model_Layer_Filter_Category
{

} 

app/etc/modules/Mycomp_All.xml:

<?xml version="1.0"?>
<config>
  <modules>
     <Mycomp_Catalog>
       <codePool>local</codePool>
       <active>true</active>
     </Mycomp_Catalog>
  </modules>
 </config> 

I’m trying to override Mage_Catalog_Model_Layer_Filter_Category.
In system.log I’m getting a warning:

Warning: include(Mycomp_Catalog_Model_Layer_Filter_Category.php): failed to open stream: No such file or directory in /var/www/magento/includes/src/Varien_Autoload.php on line 93
Warning: include(): Failed opening ‘Mycomp_Catalog_Model_Layer_Filter_Category.php’ for inclusion (include_path=’/var/www/magento/includes/src:.:/usr/share/php:/usr/share/pear’) in /var/www/magento/includes/src/Varien_Autoload.php on line 93

What am I doing wrong?

Mycomp/Catalog/etc/config.xml:

<?xml version="1.0"?>
<config>
<modules>
    <Mycomp_Catalog>
        <version>0.1.0</version>
    </Mycomp_Catalog>
</modules>
<global>
    <models>
        <catalog>
            <rewrite>                    
                <layer_filter_category>Mycomp_Catalog_Model_Layer_Filter_Category</layer_filter_category>
            </rewrite>
        </catalog>
    </models>
</global>

Mycomp/Catalog/Model/Layer/Filter/Category.php:

class Mycomp_Catalog_Model_Layer_Filter_Category extends  Mage_Catalog_Model_Layer_Filter_Category
{

} 

app/etc/modules/Mycomp_All.xml:

<?xml version="1.0"?>
<config>
  <modules>
     <Mycomp_Catalog>
       <codePool>local</codePool>
       <active>true</active>
     </Mycomp_Catalog>
  </modules>
 </config> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

软糖 2024-09-17 08:10:18

它没有出现在这里,那么您是否为 Mycomp_Catalog 模块设置了模型?像这样修改你的全局部分:

<global>
    <models>
        <catalog>
            <rewrite>                    
                <layer_filter_category>Mycomp_Catalog_Model_Layer_Filter_Category</layer_filter_category>
            </rewrite>
        </catalog>
        <mycompcatalog>
            <class>Mycomp_Catalog_Model</class>
        </mycompcatalog>
    </models>
</global>

这是我唯一的猜测。希望有帮助!

谢谢,

It doesn't appear here, so did you set up the models for the Mycomp_Catalog module? Amend your global section like this:

<global>
    <models>
        <catalog>
            <rewrite>                    
                <layer_filter_category>Mycomp_Catalog_Model_Layer_Filter_Category</layer_filter_category>
            </rewrite>
        </catalog>
        <mycompcatalog>
            <class>Mycomp_Catalog_Model</class>
        </mycompcatalog>
    </models>
</global>

That's my only guess off the bat. Hope that helps!

Thanks,
Joe

亚希 2024-09-17 08:10:18

众所周知,此类问题很难通过论坛进行调试。这是一个具有工作覆盖的模块(至少,它可以在我安装的 1.4 CE 上工作)将其与您的进行比较,看看有什么不同,或者只是尝试在您的安装上安装,如果它不起作用,您知道有一个其他地方的问题。

http://alanstorm.com/testbed/Mycomp.tar.gz

These kinds of problems are notriously difficult to debug via a forum. Here's a module with a working override (at least, it works on my install of 1.4 CE) Diff it vs. yours to see what's different, or just try installing in on your install, and if it doesn't work you know there's a problem elsewhere.

http://alanstorm.com/testbed/Mycomp.tar.gz

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