0

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:

https://sarfarazlaghari.wordpress.com/2015/09/02/magento-adding-purchase-order-number-in-sales-order-grid/

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>

2 Answers 2

0

As you mentioned, if the order was made using purchase order.
So where do you persist that PO number. The link you have added here is calling PO number from payment table. If you are expecting that value then you can go ahead with the link else you'll need additional implementation.

3
  • Persist that PO number? I am using the included purchase order payment of magento. the PO number sare kept in the table sales_flat_order_payment Apr 12, 2017 at 15:27
  • then pick that code, it should solve your problem. Apr 12, 2017 at 15:30
  • I updated my question with my solution so far, would you say it is an suitable solution ? Apr 12, 2017 at 16:18
0

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>

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.