gpt4 book ai didi

php - Magento - 覆盖 Adminhtml block

转载 作者:可可西里 更新时间:2023-10-31 23:59:48 25 4
gpt4 key购买 nike

我花了几个小时试图覆盖扩展程序中“添加商店”和“编辑商店”页面的 Magento block ,以向其添加另一个文本框。在翻阅书籍和谷歌搜索后,我发现了几个人们说有效的解决方案,但对我来说却不是。

一个建议是 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 的 block 类:

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,但它主要是创建一个顶级管理菜单并指定扩展信息,仅此而已。

有什么问题吗?一个解决方案将不胜感激!

最佳答案

如下所示,略有修改。您似乎将“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") 语法调用其他 block ,您还需要将自己的 block 添加到该代码中,如下所示。

<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>

关于php - Magento - 覆盖 Adminhtml block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1876897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com