加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Magento – 覆盖Adminhtml块

发布时间:2020-12-13 13:54:17 所属栏目:PHP教程 来源:网络整理
导读:我花了好几个小时试图覆盖扩展中“添加商店”和“编辑商店”页面的Magento块,以便为其添加另一个文本框.经过书籍和谷歌搜索后,我发现了一些人们认为有效的解决方案,但不适合我. 一项建议是this one. 我复制了Lee Saferite所谓的正确解决方案,该解决方案适用
我花了好几个小时试图覆盖扩展中“添加商店”和“编辑商店”页面的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()
    { ... }
}

该类包含新的输入字段.如果我在以下位置修改原始核心文件,则字段会完美显示:

应用程序/核心/法师/ Adminhtml /模块/系统/存储/ Edit.php

但我真的希望我的扩展能够覆盖它.如果有必要,我可以发布我的整个config.xml,但它主要创建一个顶级管理菜单,并指定扩展信息,而不是其他.

关于出了什么问题的任何想法?一个解决方案将非常感谢!

如下所示,稍作修改.看来你拼错了“编辑”为“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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读