源于我的最后一个问题,我很难尝试进行覆盖。我也在做 MudithaE在这里的回答。
我想实现_prepareColumns()
在文件中找到的我自己的app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
。我设置了模块的目录和文件,如下所示。在研究的过程中,我看到很多开发人员喜欢这样做Dev_Module_Block_Adminhtml_blah
,所以我尝试在代码中随处更改目录结构和类名。不用找了。我的 Cycleworks_SalesGridImproved 模块也出现在系统 -> 配置 -> 高级列表中。
文件
app/code/local/Cycleworks/SalesGridImproved/Adminhtml/Block/Sales/Order/Grid.php
::
<?php
class Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
protected function _prepareColumns() // tried public too
{
parent::_prepareColumns();
...
...
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'format' => 'MMM d, h:mm a',
'width' => '165px',
));
...
...
return $this;
}
}
app/code/local/Cycleworks/SalesGridImproved/etc/config.xml
:
<?xml version="1.0"?>
<config>
<modules>
<!-- also tried: Cycleworks_SalesGridImproved -->
<Cycleworks_Adminhtml>
<version>0.0.01</version>
</Cycleworks_Adminhtml>
</modules>
<global>
<blocks>
<adminhtml>
<salesgridimproved>
<class>Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid</class>
</salesgridimproved>
<rewrite>
<sales_order_grid>Cycleworks_SalesGridImproved_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
并在/app/etc/modules/Cycleworks_SalesGridImproved.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Cycleworks_SalesGridImproved>
<active>true</active>
<codePool>local</codePool>
</Cycleworks_SalesGridImproved>
</modules>
</config>
请告诉我看看我错过了什么......谢谢!
更新:
刚刚发现扩展 EM_DeleteOrder 也覆盖了与我相同的销售订单网格类。他的扩展配置比我的更复杂,因为他的设置是在 Mage 核心之前调用。config.xml 肯定很忙!
<?xml version="1.0"?>
<config>
<modules>
<EM_DeleteOrder>
<version>1.0.0</version>
</EM_DeleteOrder>
</modules>
<global>
<rewrite>
<em_emadmin_adminhtml_sales_order>
<from><![CDATA[#/admin/sales_order/#]]></from>
<to>/emadmin/adminhtml_sales_order/</to>
</em_emadmin_adminhtml_sales_order>
</rewrite>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
<admin>
<routers>
<em_deleteorder>
<use>admin</use>
<args>
<module>EM_DeleteOrder</module>
<frontName>emadmin</frontName>
</args>
</em_deleteorder>
<adminhtml>
<args>
<modules>
<EM_DeleteOrder_Adminhtml before="Mage_Adminhtml">EM_DeleteOrder_Adminhtml</EM_DeleteOrder_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
你有什么想法我可以使用类似的语法并让我的模块工作而不必破解他的代码吗?像一个after="Mage_Adminhtml"
?
最终更新: 可悲的是,下面的 3 个答案不是答案,而是扩展冲突。我会回答我自己的问题并将其标记为已回答。