简体   繁体   English

扩展Magento模型不起作用

[英]Extending Magento Model Not Working

I am trying to extend a community plugin and everything looks correct to me, but I must be missing something because my methods are not overriding the community plugins methods. 我正在尝试扩展社区插件,但一切看起来对我来说都是正确的,但是我必须缺少一些东西,因为我的方法没有覆盖社区插件方法。

The odd thing is that I downloaded the Modules Conflict Detector and it says it is my plugin is extending the community plugin just fine. 奇怪的是,我下载了模块冲突检测器 ,并说这是我的插件很好地扩展了社区插件。

app/etc/modules/KNG_M2eProMods.xml 应用程序的/ etc /模块/ KNG_M2eProMods.xml

<?xml version="1.0"?>
<config>
    <modules>
        <KNG_M2eProMods>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Ess_M2ePro/>
            </depends>
        </KNG_M2eProMods>
    </modules>
</config>

app/code/local/KNG/M2eProMods/etc/config.xml 应用程序/代码/本地/ KNG / M2eProMods的/ etc / config.xml中

<?xml version="1.0"?>
<config>
    <modules>
        <KNG_M2eProMods>
            <version>0.1.0</version>
        </KNG_M2eProMods>
    </modules>
    <global>
        <models>
            <M2ePro>
                <rewrite>
                    <magento_payment>KNG_M2eProMods_Model_Magento_Payment</magento_payment>
                    <magento_quote>KNG_M2eProMods_Model_Magento_Quote</magento_quote>
                    <magento_order>KNG_M2eProMods_Model_Magento_Order</magento_order>
                </rewrite>
            </M2ePro>
        </models>
    </global>
</config>

app/code/local/KNG/M2eProMods/Model/Magento/Order.php 应用程序/代码/本地/ KNG / M2eProMods /型号/ Magento的/ Order.php

class KNG_M2eProMods_Model_Magento_Order extends Ess_M2ePro_Model_Magento_Order
{
    private function placeOrder()
    {
     ......
    }
}

app/code/local/KNG/M2eProMods/Model/Magento/Payment.php 应用程序/代码/本地/ KNG / M2eProMods /型号/ Magento的/ Payment.php

class KNG_M2eProMods_Model_Magento_Payment extends Ess_M2ePro_Model_Magento_Payment
{
    protected $_code = 'payment_profile';
}

app/code/local/KNG/M2eProMods/Model/Magento/Quote.php 应用程序/代码/本地/ KNG / M2eProMods /型号/ Magento的/ Quote.php

class KNG_M2eProMods_Model_Magento_Quote extends Ess_M2ePro_Model_Magento_Quote
{
    private function initializeQuoteItems()
    {
     ......
    }
}

Here is a snippet from the config.xml of the plugin I am trying to extend. 这是我要扩展的config.xml的摘录。 app/code/community/Ess/M2ePro/etc/config.xml 应用程序/代码/社区/ ESS / M2ePro的/ etc / config.xml中

......
<models>
        <M2ePro>
            <class>Ess_M2ePro_Model</class>
            ......
        </M2ePro>
        ......
</models>
......

Here are the file paths I am extending. 这是我要扩展的文件路径。

app/code/community/Ess/M2ePro/Model/Magento/Order.php
app/code/community/Ess/M2ePro/Model/Magento/Payment.php
app/code/community/Ess/M2ePro/Model/Magento/Quote.php

Thanks for the help 谢谢您的帮助

Your config.xml is not set properly. 您的config.xml设置正确。 Magento is case sensitive in reading the xml files. Magento在读取xml文件时区分大小写 So your config.xml file should be like this, 所以您的config.xml文件应该是这样的,

<?xml version="1.0"?>
<config>
  <modules>
    <KNG_M2eProMods>
      <version>0.1.0</version>
    </KNG_M2eProMods>
  </modules>
  <global>

    <models>
      <m2epromods>
        <class>KNG_M2eProMods_Model</class>
        <resourceModel>m2epromods_mysql4</resourceModel>
      </m2epromods>
            <m2epro>
                <rewrite>
                    <magento_order>KNG_M2eProMods_Model_M2ePro_Magento_Order</magento_order>
                </rewrite>
            </m2epro>
            <m2epro>
                <rewrite>
                    <magento_payment>KNG_M2eProMods_Model_M2ePro_Magento_Payment</magento_payment>
                </rewrite>
            </m2epro>
            <m2epro>
                <rewrite>
                    <magento_quote>KNG_M2eProMods_Model_M2ePro_Magento_Quote</magento_quote>
                </rewrite>
            </m2epro>
    </models>
  </global>
</config> 

Please comment here if you have any doubt. 如有任何疑问,请在这里评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM