How to Add new columns in order Grid Magento
You can Add new columns in order Grid Magento
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.product_id SEPARATOR ",")'),
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
'quantities' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR ",")'),
)
);
$collection->getSelect()->joinLeft(array('odtx1'=>'table_name'),'odtx1.product_id = `sales/order_item`.product_id',array('odtx1.sale_name'));
$collection->getSelect()->joinLeft(array('odtx2'=>' table_name '),'odtx2.vsaletitle = odtx1.sale_name',array('odtx2.supplier_id'));
$collection->getSelect()->joinLeft(array('odtx3'=>' table_name '),'odtx3.supplier_id = odtx2.supplier_id',array('odtx3.s_name'));
$this->setCollection($collection);
$collection->getSelect()->group('entity_id');
return parent::_prepareCollection();
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.product_id SEPARATOR ",")'),
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
'quantities' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR ",")'),
)
);
$collection->getSelect()->joinLeft(array('odtx1'=>'table_name'),'odtx1.product_id = `sales/order_item`.product_id',array('odtx1.sale_name'));
$collection->getSelect()->joinLeft(array('odtx2'=>' table_name '),'odtx2.vsaletitle = odtx1.sale_name',array('odtx2.supplier_id'));
$collection->getSelect()->joinLeft(array('odtx3'=>' table_name '),'odtx3.supplier_id = odtx2.supplier_id',array('odtx3.s_name'));
$this->setCollection($collection);
$collection->getSelect()->group('entity_id');
return parent::_prepareCollection();
}
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment