3
votes

I'm working on a module and I need a block file to be overridden in order to add new functionality. I know how to override blocks, model and controllers but I want to know that what will happen if the class I'd extended was being used by another module class?

The above scenario is as follows:
In my module config.xml I'd overridden a block file as:

<blocks>
    <checkout>
        <rewrite>
            <cart_shipping>Company_Module_Block_Cart_Shipping</cart_shipping>
        </rewrite>
    </checkout>
</blocks>

and override a method getEstimateRates()

but there's another module whose block file extends Mage_Checkout_Block_Cart_Shipping. My question is -

"Will that class be able to see the changes made in the overridden class in my module?"

OR

"Do I have to override the other modules block file?"

2
This could be helpful https://stackguides.com/questions/23884838/how-to-override-community-block-module-with-php-file-in-magento/23885156#23885156Slimshadddyyy
that's one of the reasons you shouldn't override but use events insteadOSdave

2 Answers

1
votes

One of yours or another extend block will not work. It can be fixed by extending yours or another block from one of them.

For example Company_Module_Block_Cart_Shipping is your block and Other_Module_Block_Cart_Shipping is other block.

If Other_Module_Block_Cart_Shipping is extended from core, you have to extend your Company_Module_Block_Cart_Shipping from Other_Module_Block_Cart_Shipping

0
votes

Magento makes a config.xml tree of all the config.xml of enabled modules.

Mage_All.xml is loaded first, then all Mage.*.xml and preceding it your custom module .xml as per alphabetic sequence.

The sequence can be changed if you have given a depends tag in etc/modules/module definition xml.

Hope this clears your doubt.