0
votes

I created a module using the module creator.

I am trying to overwrite Adminhtml\Block\Sales\Order\Grid.php

class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid

and my overwritten block is in local\Delivery\Date\Block\Sales\Order\Grid.php

class Delivery_Date_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid

and the function to overwrite is

protected function _prepareColumns()
    {

I face a strange problem when I try to overwrite a function in my module Block the change are not affected instead if I comment out the same function lines in the Mage folder my function is overwritten.

Suppose i have a function in local\Delivery\Date\Block\Sales\Order\Grid.php as

protected function _prepareColumns()
    {

        $this->addColumn('real_order_id', array(
            'header'=> Mage::helper('sales')->__('Order NEW ID#'),
            'width' => '80px',
            'type'  => 'text',
            'index' => 'increment_id',
        ));}

noting happens instead if I comment/delete the line in Adminhtml\Block\Sales\Order\Grid.php

protected function _prepareColumns()
    {

        $this->addColumn('real_order_id', array(
            'header'=> Mage::helper('sales')->__('Order #'),
            'width' => '80px',
            'type'  => 'text',
            'index' => 'increment_id',
        ));

Then only my changes are affected in the adminhtml grid. Why is the fallback changes happening ?

config.xml

<blocks>
     <adminhtml>
                <rewrite>
                  <sales_order_grid>Delivery_Date_Block_Sales_Order_Grid</sales_order_grid>
                </rewrite>
     </adminhtml>
</blocks>
2
please edit your question to add the part of your config.xml where you declare the overrideOSdave

2 Answers

0
votes

can you try if this works for you:

    protected function _prepareColumns()
    {
        parent::_prepareColumns();

        $this->removeColumn('real_order_id');

        $this->addColumn('real_order_id', array(
            'header' => Mage::helper('sales')->__('Order NEW ID#'),
            'width'  => '80px',
            'type'   => 'text',
            'index'  => 'increment_id',
        ));
    }
0
votes

You need changed extends class

class Delivery_Date_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid

See example for overide Grid http://inchoo.net/ecommerce/magento/how-to-extend-magento-order-grid/