Stemming from my last question, I am stumped trying to do an override. I am doing exactly what MudithaE's answer here did, too.
I want to implement my own _prepareColumns()
as found in the file app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
. I set up my module's directories and the files as below. While researching, I saw a lot of developers like to do Dev_Module_Block_Adminhtml_blah
, so I tried changing the directory structure and class names everywhere in my code. No change. My Cycleworks_SalesGridImproved module appears in the System -> Config -> Advanced listing, too.
Files:
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>
And in /app/etc/modules/Cycleworks_SalesGridImproved.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Cycleworks_SalesGridImproved>
<active>true</active>
<codePool>local</codePool>
</Cycleworks_SalesGridImproved>
</modules>
</config>
Please show me see what I'm missing... Thanks!
Update:
Just found out the extension EM_DeleteOrder is also overriding the same sales order grid class that I am. His extension's configuration is more complicated than mine, as his is set up to be called before the Mage core. The config.xml sure is busy!
<?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>
Do you have any thoughts how I can use similar syntax and get my module to work and not have to hack his code? Like with an after="Mage_Adminhtml"
?
Final Update: Sadly, the 3 answers below weren't the answer, it was the extension conflict. I'll answer my own question and mark it answered.
I'm answering myself, as this was a big lesson in extension conflicts and their resolution. Further, I learned a lot about our particular installation and how sloppy extensions can break everything.
As in the update, EM_DeleteOrder was overriding Adminhtml Block Sales Order Grid (absog
). I also used the extension MDN_ExtensionConflict and while it wasn't detecting my exact conflict, it did show me that EM_DeleteOrder was using absog
. I searched for extensions that would allow deletion of orders without using absog
, which must be the easy way to go about it.
The extension Asperience_DeleteAllOrders manages to do this without overwriting the whole page and instead catches something in the router. Its config.xml
is abstract art to me, so if you're an advanced developer, I think you'd appreciate his work more than I.
Ultimately, I found MageWorx_ExtendedOrders which replaces the entire absog
with their own grid and has configurable additional columns. Included are custom shipping rates, order editing, deletion of orders, and order archiving. I am impressed with this extension for $149. I also am going through deleting the multiple extensions that were replaced with MageWorx_ExtendedOrders. I'm hacking their extension's code to put the columns in my desired order and to update the date format (and I'll share my changes with them as feature suggestions).