我花了几个小时试图在一个扩展中覆盖"Add store“和"Edit store”页面的Magento块,以便在其中添加另一个文本框。在翻阅书籍和谷歌搜索后,我发现了几个人们认为有效的解决方案,但对我来说不是。
其中一个建议是this one。
我抄袭了Lee Saferite的所谓正确的解决方案,它适用于原始海报,但不适用于我。当然,我将值更改为要覆盖的类和新修改的类。
我的config.xml (相关部分):
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_sdit_form>Nintera_General_Block_StoreEdit</system_store_sdit_form>
</rewrite>
</adminhtml>
</blocks>
<resources></resources>
<helpers>
<Nintera_General>
<class>Nintera_General_Helper</class>
</Nintera_General>
</helpers>
</global>和位于Nintera/General/ block /StoreEdit.php的块类:
class Nintera_General_Block_StoreEdit extends Mage_Adminhtml_Block_System_Store_Edit_Form
{
/**
* Prepare form data
*
* return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{ ... }
}该类包含新的输入字段。如果我在以下位置修改原始核心文件,这些字段会完美地显示出来:
app/core/Mage/Adminhtml/Block/System/Store/Edit.php
但我真的希望我的扩展能覆盖它。如果有必要,我可以发布我的整个config.xml,但它主要是创建一个顶级管理菜单和指定扩展信息,没有太多其他。
你知道哪里出问题了吗?如果能有一个解决方案,我们将非常感谢!
发布于 2009-12-10 23:12:47
如下图所示,但稍作修改。看起来你把"edit“拼写成了"sdit”。
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_edit_form>Nintera_General_Block_StoreEdit</system_store_edit_form>
</rewrite>
</adminhtml>
</blocks>
</global>还要记住,如果您希望使用Mage::getModel("nintera_general/myblock")语法调用其他块,则还需要将您自己的块添加到该代码中,如下所示。
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_edit_form>Nintera_General_Block_StoreEdit</system_store_edit_form>
</rewrite>
</adminhtml>
<nintera_general>
<class>Nintera_General_Block</class>
</nintera_general>
</blocks>
</global>发布于 2012-06-01 13:05:47
在阅读了几篇帖子之后,我找到了覆盖Mage_Adminhtml_Block_Widget_Grid这个问题的解决方案。
正如在此thread中提到的
“您只能在配置中覆盖(重写)实例化的块。您不能将任何内容注入到类层次结构中,因为PHP不支持它”
我想重写protected function _addColumnFilterToCollection($column)方法
用于Mage_Adminhtml_Block_Sales_Order_Grid的扩展层次结构。
我没有覆盖Mage_Adminhtml_Block_Widget_Grid,而是覆盖了类Mage_Adminhtml_Block_Sales_Order_Grid,并将我的函数放在那里。
对我来说,这很好用。
https://stackoverflow.com/questions/1876897
复制相似问题