【问题标题】:Magento. Unable to rewrite Address modelMagento。无法重写地址模型
【发布时间】:2014-03-13 17:39:51
【问题描述】:

我正在尝试重写 Magento 地址模型,但我对此感到抓狂。我的 config.xml 重写部分如下所示

<models>
    <customer>
         <rewrite>
             <customer>MyNam_MyMod_Model_Customer</customer>
             <address>MyNam_MyMod_Customer_Model_Address</address>
         </rewrite>
    </customer>
</models>

我的班级看起来像:

require_once 'Mage/Customer/Model/Address.php';
class MyNam_MyMod_Customer_Model_Address extends Mage_Customer_Model_Address
{


public function validate() {
    parent::validate();
}
}

当我加载地址表单时,我收到以下错误:在 /var/www/magento/app/code/core/Mage/Customer/Block/ 中的非对象上调用成员函数 getId()地址/Edit.php 第 53 行

我注意到编辑块无法加载客户/地址模型

谁能帮帮我?

【问题讨论】:

    标签: php magento rewrite


    【解决方案1】:

    我希望在课堂地址MyNam_MyMod_Customer_Model_Address,我应该是MyNam_MyMod_Model_Address

    <models>
        <customer>
             <rewrite>
                 <customer>MyNam_MyMod_Model_Customer</customer>
                 <address>MyNam_MyMod_Model_Address</address>
             </rewrite>
        </customer>
    </models> 
    

    如果您有任何问题,请告诉我...

    【讨论】:

      【解决方案2】:

      首先删除require_once 'Mage/Customer/Model/Address.php';这一行 你不需要这个,因为类是自动加载的。 您的其余代码看起来是正确的。您是否清除了 var/cache 文件夹?

      【讨论】:

        猜你喜欢
        • 2012-12-22
        • 2016-02-28
        • 2013-10-15
        • 2015-12-08
        • 1970-01-01
        • 2011-05-02
        • 2011-10-18
        • 2016-01-09
        相关资源
        最近更新 更多