April 08, 2020

cm-mini

Thinking Magento

M2Epro Multi Channel Extension - How To Add Information To Sales_Order_Grid

If you're running M2EPro's Multi Channel Extension for ebay, play, amazon extension and you would like to add some of that information to your Sales_Order_Grid to save time navigating through the M2EPro menus and grids, the following information may prove to be useful for you.

In this instance we are going to add the ebay username to the Sale_Order_Grid so that we can perform lookups by ebay username

Copy from your core files Mage_Adminhtml_Block_Sales_Order_Grid into local 

Find function _prepareCollection()

Under $collection = Mage::getResourceModel($this->_getCollectionClass());

Addd the following code

$collection->getSelect()->joinLeft(array('m2eo'=>'m2epro_order'),'m2eo.magento_order_id=main_table.entity_id',array('m2eo.id')); 
$collection->getSelect()->joinLeft(array('m2eoi'=>'m2epro_order_item'),'m2eoi.order_id=m2eo.id',array('m2eoi.order_id')); 
$collection->getSelect()->joinLeft(array('m2eoe'=>'m2epro_ebay_order'),'m2eoe.order_id=m2eoi.order_id',array('m2eoe.buyer_user_id'));

What we are doing here is joinging 3 tables in the databse together. 

The first table we join is m2epro_order and match it up to the order_id of our magento orders. From m2epro_order the data we want to get is the id column.

Then we join m2epro_order_item but comparing the m2epro_order.id with m2epro_order_item.order_id. From m2epro_order_item the data we want to get is the order_id column.

Using the above 2 joins you now have access to the m2epro orders, which can perform look ups in ebay, amazon, play.

For this example we only require ebay usernames, but you could perform a CONCAT on amazon and ebay usernames together.

The final join is looking in m2epro_ebay_order joining m2epro_ebay_order.order_id to m2epro_order_item.order_id. This gives us the data we require to place the usernames on the grid.

Now adding your column to the grid, go down to function _prepareColumns()

$this->addColumn('buyer_user_id', array(
'header' => Mage::helper('sales')->__('User Id'),
'index' => 'buyer_user_id',
));

Save. Job complete