問題描述
在 Magento 中,您可以從一個模塊中的另一個模塊(最常見的是 Magento Adminhtml 模塊)覆蓋塊(或助手,或模型等).現在我有一個問題,我想覆蓋一個已經被其他擴展覆蓋的塊.有什么方法可以告訴 magento 忽略一些其他模塊配置中的
標簽,類似于布局更新中的
標簽?
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>
我將 Symmetrics_DeliveryTime
中的塊的功能集成到我自己的塊中,現在我希望 magento 忽略從該模塊覆蓋的塊.
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.
是否有任何 magento 方法可以做到這一點,或者是注釋掉配置(這是我現在所做的)的唯一方法,包括以后更新該模塊時的所有麻煩?
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?
推薦答案
如果您將模塊設置為依賴于"也在進行重寫的模塊,那么您的配置將最后讀取并且重寫應該堅持,在適當的您應該擁有的 app/etc/modules 中的文件:
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>
這篇關于覆蓋多個模塊中的 magento 塊(以及如何忽略其他模塊)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!