Question

For one of my module I’m trying to rewrite the class Mage_Sales_Model_Quote_Address_Total_Subtotal. I used to rewrite models, no problem with that. I understand that the abstract classes cannot be rewritten. But this one, I’m stuck ...

My aim is to rewrite protected function _initItem($address, $item), I have failed, and tryed to rewrite every function (with parent:: replacement by grandparent class). No more luck for me.

Here is my config :

<!-- 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> 

And my class :

# 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");
}
}

Can anyone help me with that ? Seems to be the same problem as an abstract class so far.

Was it helpful?

Solution

This

<sales_quote>
        <rewrite>
            <address_total_subtotal>Mynamespace_Mymodule_Model_Sales_Quote_Address_Total_Subtotal</address_total_subtotal>
        </rewrite>
    </sales_quote>

Should be

<sales>
        <rewrite>
            <quote_address_total_subtotal>Mynamespace_Mymodule_Model_Sales_Quote_Address_Total_Subtotal</quote_address_total_subtotal>
        </rewrite>
    </sales>

OTHER TIPS

Here is some notes given on image, try to understand how to create model names and rewrite in config.xml: Model rewrite

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top