Magento Forum

Add a field to the sales/order grid
 
AndrewNS
Jr. Member
 
Total Posts:  1
Joined:  2012-01-25
 

I have a custom extenion installed that saves an order comment and a customer selected delivery date. I would like the delivery date to appear on the sales/order grid.

I modified grid.php in apps/code/core/Mage/Adminhtml/Block/Sales/Order and the column now shows up in the sales/order grid. But, there is no data.

$this->addColumn(’delivery_date’, array(
‘header’ => Mage::helper(’sales’)->__(’Delivery Date’),
‘index’ => ‘delivery_date’,
‘type’ => ‘datetime’,
));

The data is in a table mage_sales_ddc_order (field name delivery_date)

Do I have to add the field to the sales/order_grid_collection? If so, how is it added?

Thanks
Andrew

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shaun E.
Member
 
Total Posts:  65
Joined:  2009-06-24
 

I think you\’ll have to join that other table.  I can\’t remember the syntax for joining tables (in magento) right now, but I do know you\’ll have to override the _prepareCollection() function in Mage_Adminhtml_Block_Sales_Order_Grid.  Something like this…

protected function _prepareCollection()
    
{
        parent
::_prepareCollection();
        
$collection $this->getCollection();
        
// Now your code to join to the other table... so sorry I can\'t remember off the top of my head
        // Should be websites/forums/stackoverflow answers as to how to join tables
        
$this->setCollection($collection);
        return 
$this;
    
}

This is the function that prepares the db query, and if you haven\’t already joined over to the other table there is no chance the data will show in your grid.  Best of luck.

Edit:
Looks like the guys a inchoo have already blogged about this before…
http://inchoo.net/ecommerce/magento/how-to-extend-magento-order-grid/

 
Magento Community Magento Community
Magento Community
Magento Community
 
webkul
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2010-10-27
 

you may find a working demo here : http://webkul.com/blog/customer-email-in-magento-sales-order-grid/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Hi!
With this extension you can have additional columns on your order grid - Extended Order Grid.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top