Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overriding a magento block in multiple modules (and how to ignore the other ones)

In Magento you can override a block (or helper, or model, etc.) from one module in another one (most common from Magento Adminhtml module). Now I have the problem that I want to override a block that was already overriden by some other extension. Is there any way to tell magento to ignore the <rewrite> tag in some other module configuration similary to the <remove> tag in layout updates?

Here is the configuration of the other extension:

    <blocks>
        <adminhtml>
            <rewrite>
                    <catalog_product_grid>Symmetrics_DeliveryTime_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
            </rewrite>
        </adminhtml>
    </blocks>

Here the configuration of my extension:

    <blocks>
        <adminhtml>
            <rewrite>
                    <catalog_product_grid>Namespace_MyModule_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
            </rewrite>
        </adminhtml>
    </blocks>

I integrated the functionality of the block from Symmetrics_DeliveryTime into my own block and now I want magento to ignore the block overriding from that module.

Is there any magento way to do that or is the only way to comment out the configuration (which is what I have done for now) including all the hassle while updating that module later?

like image 978
Uwe Mesecke Avatar asked Jan 29 '10 12:01

Uwe Mesecke


1 Answers

If you set your module to 'depend' on the one that's also doing a rewrite, your config will be read last and the rewrite should stick, in the appropriate file within app/etc/modules you should have:

<config>
  <modules>
    <Your_Module>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Other_Module/>
      </depends>
    </Your_Module>
  <modules>
<config>
like image 57
Greg Avatar answered Nov 05 '22 23:11

Greg