I am using Magento 1.9.3.2 and I have got payment method to show along wits order sku's following:
https://www.atwix.com/magento/adding-sku-column-to-orders-grid/
But, I would also find it rather useful to have the purchase order number on the grid if the order was made using purchase order.
Would anyone know how l could add this field into my order grid ?
Still, looking to get this sorted and I have found this possible solution:
Would this be a suitable solution or is there a better way?
Line 33 from the Atwix observer has this line:
$select->joinLeft(array('payment' => $collection->getTable('sales/order_payment')), 'payment.parent_id=main_table.entity_id', array('payment_method' => 'method'));
If I change 'method' to 'po_number' I can see the Purchase order numbers in payment method column in the grid.
My solution so far:
I have amended app/code/local/Atwix/ExtendedGrid/Model/Observer.php on line 34 so now, the function looks as such:
public function salesOrderGridCollectionLoadBefore($observer) { $collection = $observer->getOrderGridCollection(); $select = $collection->getSelect(); $select->joinLeft(array('payment' => $collection getTable('sales/order_payment')),'payment.parent_id=main_table.entity_id',array('payment_method' =>'method', 'po_number' => 'po_number')); $select->join('sales_flat_order_item','`sales_flat_order_item`.order_id=`main_table`.entity_id',array('skus' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ", ")'))); $select->group('main_table.entity_id'); }
Then I updated app/design/adminhtml/default/default/layout/atwix/extendedgrid.xml by adding:
<action method="addColumnAfter"> <columnId>po_number</columnId> <arguments> <header>PO Number</header> <index>po_number</index> <filter_index>payment.po_number</filter_index> <type>text</type> </arguments> <after>payment_method</after> </action>