0

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.

2

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>
3
  • This is it ! I found a tutorial, for some models like Mage_CatalogInventory_Model_Stock_Item_Api_V2 you have to put cataloginventory_stock before the rewrite tag. Can you explain me that point please ? Thank you very much by the way ! – guillaume_shm Oct 8 '13 at 8:04
  • @guillaume_shm if you post a link I can try to explain – Marius Oct 8 '13 at 8:21
  • thanks for your contribution, I found that it was the aliases defined in the core config.xml associated to the class I want to rewrite. So far, I'm good and I have totally understood how it work. Thank you very much again ! – guillaume_shm Oct 8 '13 at 8:29
0

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

1
  • Oh clever explanation, thank you very much mageUz ! – guillaume_shm Oct 8 '13 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.