I am stuck with adding new column(Shipped date) to sales order admin grid. I copied the file Grid.php from app/code/core/Mage/Adminhtml/Block/Sales/Order to app/code/local/Mage/Adminhtml/Block/Sales/Order and in the _prepareCollection() function added the code

$collection->getSelect()->joinLeft('sales_flat_shipment_grid','sales_flat_shipment_grid.order_id=main_table.entity_id',array('shipped_date' => 'sales_flat_shipment_grid.created_at'));

and in _prepareColumns() added this

$this->addColumn('shipped_date', array(
      'header'    => Mage::helper('sales')->__('Shipped Date'),
      'index'     => 'shipped_date',
      'type'      => 'datetime',

My problem is when there are orders with multiple shipments and when I go to the sales order grid I get the error There has been an error processing your request which says there is a duplicate order id. If there are no multiple shipments for orders, then the sales order grid is fine and shows the shipped date for the corresponding orders.

Could someone help me with this?

2 Answers 2


As the order can has multiple shipments, you may use sub-query:

  1. in the _prepareCollection()

    $table = Mage::getSingleton('core/resource')
    $shipping = "((select max(t.created_at) from `$table` as t where t.order_id=main_table.entity_id))";
    $collection->getSelect()->from('', "$shipping as shipped_date");   
  2. in the _prepareColumns():

    $this->addColumn('shipped_date', array( 'header' => Mage::helper('sales')->__('Shipped Date'), 'index' => 'shipped_date', 'type' => 'datetime', ));

  • Your answer seems to be incomplete, as it doesn't show how to filter by the shipped_date when 'fromDate' and 'toDate' values are given to column filter.
    – Vicky Dev
    Commented Dec 27, 2016 at 21:00

You could use the renderer instead, and this without joining with the shipment grid.

$this->addColumn('shipped_date', array(
      'header'    => Mage::helper('sales')->__('Shipped Date'),
      'index'     => 'entity_id',
      'type'      => 'datetime',
      'renderer'  => 'Mage_Adminhtml_Block_Sales_Order_Renderer_ShippedDate',
                                       => array($this, '_filterShippedDate'),


You should create the renderer in your module, and to define your filter function, and you are gonna have the shipped dates, no matter how much shipment you have.

  • Thanks Quafae. I am not familiar with creating a renderer. Can you point me towards how to do this?
    – James
    Commented Dec 8, 2014 at 5:46
  • inchoo.net/magento/…
    – Keyul Shah
    Commented Dec 8, 2014 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.