我需要覆盖core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php
目前我有模块Bv
和名称空间Discounts
我的config.xml
是
<config>
<global>
<models>
<discounts>
<class>Bv_Discounts_Model</class>
<!--
need to create our own resource, can't just
use core_resource
-->
<resourceModel>discounts_resource</resourceModel>
</discounts>
<discounts_resource>
<class>Bv_Discounts_Model_Resource</class>
<!--<deprecatedNode>discounts_mysql4</deprecatedNode>-->
<entities>
<accumulative>
<table>bv_discounts_promo_catalog_accumulative</table>
</accumulative>
</entities>
</discounts_resource>
</models>
<blocks>
<discounts>
<rewrite>
<promo__catalog_edit_tab_actions>
Bv_Discounts_Block_Promo_Catalog_Edit_Tab_Actions
</promo__catalog_edit_tab_actions>
</rewrite>
</discounts>
</blocks>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<bv_discounts before="Mage_Adminhtml">Bv_Discounts</bv_discounts>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
和班级
class Bv_Discounts_Block_Promo_Catalog_Edit_Tab_Actions
extends Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_Actions
{
protected function _prepareForm()
{
$model = Mage::registry('current_promo_catalog_rule');
$form = new Varien_Data_Form(); ....
Wot是错的?
https://magento.stackexchange.com/questions/3037/how-to-override-mage-checkout-block-links
和
http://www.pierrefay.com/rewrite-modify-block-magento-92
这篇文章说我的代码必须有效,但事实并非如此!
修改
更改config.xml后
<blocks>
<adminhtml>
<rewrite>
<promo_catalog_edit_tab_actions>Bv_Discounts_Block_Promo_Catalog_Edit_Tab_Actions</promo_catalog_edit_tab_actions>
</rewrite>
</adminhtml>
</blocks>
看起来magento看到我的新重载类,当我将die();
添加到function _prepareForm()
并且页面的一部分崩溃(在浏览器中),但是当我添加一些功能代码时 - 什么也没发生!
答案 0 :(得分:0)
乍一看,这在config.xml中是错误的
<blocks>
<discounts>
<rewrite>
<promo__catalog_edit_tab_actions>
Bv_Discounts_Block_Promo_Catalog_Edit_Tab_Actions
</promo__catalog_edit_tab_actions>
</rewrite>
</discounts>
</blocks>
应该是
<blocks>
<adminhtml>
<rewrite>
<promo_catalog_edit_tab_actions>Bv_Discounts_Block_Promo_Catalog_Edit_Tab_Actions</promo_catalog_edit_tab_actions>
</rewrite>
</adminhtml>
</blocks>