我要覆盖的课程是 app \ code \ community \ Dhl \ Intraship \ Model \ Gateway.php 。所以我将该类放在 app \ code \ local \ MyCompany \ Intraship \ Model \ Gateway.php 的本地模块中,并相应地更改了类名。
现在我需要添加到我的config.xml文件才能使其正常工作?
谢谢!
答案 0 :(得分:6)
models
下的节点应与app\code\community\Dhl\Intraship\etc\config.xml
中的相同节点匹配:
<?xml version="1.0"?>
<config>
<modules>
<Dhl_Intraship>
<version>13.07.04</version>
</Dhl_Intraship>
</modules>
<!-- some more code here -->
<global>
<models>
<intraship> <!-- this is the node you have to look at -->
<class>Dhl_Intraship_Model</class>
<resourceModel>intraship_mysql4</resourceModel>
</intraship>
<!-- some more code here -->
</models>
<!-- some more code here -->
<global>
</config>
rewrite
下的节点必须匹配要在文件夹Model下重写的文件的路径:所以在你的情况下它只是gateway
。但是,如果您要重写app\code\community\Dhl\Intraship\Model\Path\To\Some\Model.php
,则该节点将为path_to_some_model
所以看起来应该是这样的:
<?xml version="1.0"?>
<config>
<modules>
<mycompany_intraship>
<version>0.1.0</version>
</mycompany_intraship >
</modules>
<global>
<models>
<intraship>
<rewrite>
<gateway>MyCompany_Intraship_Model_Gateway</gateway>
</rewrite>
</intraship>
</models>
</global>
</config>