Magento -> 重写模型

标签 magento rewrite

我想重写模型:

Mage_Sales_Model_Quote_Address

但我使用的附加组件“Payone”已经覆盖了它:

        <sales>
            <rewrite>
                <quote_address>Payone_Core_Model_Sales_Quote_Address</quote_address>
            </rewrite>
        </sales>

我试过:

        <core>
            <rewrite>
                <sales_quote_address>Mycomp_Mymod_Model_Quote_Address</sales_quote_address>
            </rewrite>
        </core>

但这行不通。有什么提示吗?

最佳答案

除非我忘记了,否则你会想让你的模块“依赖于”他们的模块,这样你的重写就会最后发生并生效。为此,您可以将以下内容添加到节点内的 app/etc/modules/My_Module.xml 文件中:

<depends>
     <Their_Module />
</depends>

一旦你这样做了,让你的类(class)扩展他们的类(class):

class My_Module_Model_Quote_Address extends Payone_Core_Model_Sales_Quote_Address

如果您可以使用事件观察器做您需要的事情,那么就去做吧。但如果您需要重写,以上内容将带您到达所需位置。

关于Magento -> 重写模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14216778/

相关文章:

php - Magento - 从后台管理员向发票添加评论

Magento 2 安装语言包(nl_NL 翻译)

image - 在 magento 中压缩上传的图像

使用优惠券代码进行 Magento 税收计算

apache - RewriteModule 上的 'SCRIPT_FILENAME' 和 'REQUEST_FILENAME' 有什么区别?

php - 重写文件扩展名但拒绝直接访问文件

magento - 在Magento中如何获取AccessToken和Access Secret Token

wordpress - 允许多个 IP 通过 .htaccess 访问 Wordpress Site Admin

.htaccess 重定向,如果 url 中的文件夹名称

nginx - nginx服务器配置:文件夹的子域