【发布时间】:2013-10-15 00:03:20
【问题描述】:
对于我的一个模块,我正在尝试重写 Mage_Sales_Model_Quote_Address_Total_Subtotal 类。 我曾经重写模型,没有问题。我知道抽象类不能被重写。 但是这个,我卡住了……
我的目标是重写受保护的函数 _initItem($address, $item),我失败了,并尝试重写每个函数(用 parent:: 替换祖父类)。我再也没有运气了。
这是我的配置:
<!-- in app/code/local/Mynamespace/Mymodule/etc/config.xml -->
<?xml version="1.0"?>
<config>
<global>
<models>
<sales_quote>
<rewrite>
<address_total_subtotal>Mynamespace_Mymodule_Model_Sales_Quote_Address_Total_Subtotal</address_total_subtotal>
</rewrite>
</sales_quote>
</models>
</global>
</config>
还有我的班级:
# in app/code/local/Mynamespace/Mymodule/Model/Sales/Quote/Address/Total/Subtotal.php
class Mynamespace_Mymodule_Model_Sales_Quote_Address_Total_Subtotal extends Mage_Sales_Model_Quote_Address_Total_Subtotal
{
protected function _initItem($address, $item)
{
Mage::log("rewrite");
}
}
谁能帮我解决这个问题?到目前为止,似乎与抽象类存在相同的问题。
【问题讨论】:
标签: class magento rewrite overriding