問(wèn)題描述
在 Magento 中,您可以從一個(gè)模塊中的另一個(gè)模塊(最常見(jiàn)的是 Magento Adminhtml 模塊)覆蓋塊(或助手,或模型等).現(xiàn)在我有一個(gè)問(wèn)題,我想覆蓋一個(gè)已經(jīng)被其他擴(kuò)展覆蓋的塊.有什么方法可以告訴 magento 忽略一些其他模塊配置中的
標(biāo)簽,類(lèi)似于布局更新中的
標(biāo)簽?
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?
這里是另一個(gè)擴(kuò)展的配置:
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>
這里是我的擴(kuò)展的配置:
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
中的塊的功能集成到我自己的塊中,現(xiàn)在我希望 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 方法可以做到這一點(diǎn),或者是注釋掉配置(這是我現(xiàn)在所做的)的唯一方法,包括以后更新該模塊時(shí)的所有麻煩?
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?
推薦答案
如果您將模塊設(shè)置為依賴于"也在進(jìn)行重寫(xiě)的模塊,那么您的配置將最后讀取并且重寫(xiě)應(yīng)該堅(jiān)持,在適當(dāng)?shù)哪鷳?yīng)該擁有的 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>
這篇關(guān)于覆蓋多個(gè)模塊中的 magento 塊(以及如何忽略其他模塊)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!