Reputation: 23
I'm stuck with adding column to sales order grid from shipment grid. The problem is: "Purchased On" in DB has name "created_at", "Date Shipped" has also name "created_at", so when I join "created_at" from "sales_flat_shipment_grid" I see purchased on date only with name date shipped. I'm using this code: in _prepareCollection()
$collection->getSelect()->joinLeft(array('sfsg'=>'sales_flat_shipment_grid'),'sfsg.order_increment_id=main_table.increment_id',array('sfsg.created_at'));
and in _prepareColumns()
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Date Shipped'),
'index' => 'created_at',
'type' => 'datetime',
'filter_index'=>'sfsg.created_at',
));
Could you please help me with this?
Upvotes: 0
Views: 1366
Reputation: 23
After few hours of trying I've found answer in my case it is: in _prepareCollection() add
$collection->getSelect()->joinLeft(array('sfsg'=>$resource->getTableName('sales_flat_shipment_grid')),'sfsg.order_increment_id=main_table.increment_id',array(
'shiped' => new Zend_Db_Expr('group_concat(sfsg.created_at SEPARATOR " | ")'), ));
and in _prepareColums()
$this->addColumn('shiped', array(
'header' => Mage::helper('sales')->__('Date Shipped'),
'index' => 'shiped',
'type' => 'datetime',
'filter_index'=>'sfsg.created_at',
));
Upvotes: 0