Moving a Magento Block from Two Different Modules

Hi, I have some problems redefining the main magento block. In my module I need to override Mage_Catalog_Block_Navigation

<blocks> <catalog> <rewrite> <navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation> </rewrite> </catalog> </blocks> 

but this is already overridden by another magento extension from another company:

 <blocks> <catalog> <rewrite> <navigation>Othercompany_Othermodule_Block_Navigation</navigation> </rewrite> </catalog> </blocks> 

Both extensions override different methods and they do not know each other, but magento reads the second redefining company, not mine. I do not want to use module dependencies. Is there a way to not violate the two extension functions.

+4
source share
2 answers

Yes, you need to decide which one officially overwrites the main unit. Let this inherit the one that does not override, and inherit its main one.

 My_Custom_Block extends Other_Custom_Block Other_Custom_Block extends Mage_Core_Block Mage_Core_Block extends Whatever_Magento_Wants 

Modify the config.xml files so that only My_Custom_Block is the one that overlaps the main block.

EDIT XML is needed here:

 <blocks> <catalog> <rewrite> <navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation> </rewrite> </catalog> </blocks> 
+7
source

thanks max. I think, as your example, that "My_Custom_Block" should be the last hierarchical class, so you don’t touch anything in the class "Other_Custom_Block".

Then you only need to comment on the rewrite rule in the config.xml of another company.

0
source

Source: https://habr.com/ru/post/1396843/


All Articles