Magento Forum

How do I join sales/order and sales/order_grid by enrty_id
 
cismerc
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2012-10-04
 

There is an ‘oder_channelname’ attribute inside the sales/order_grid table and I need to join it with the sales/order table. Can some please point me in the right direction? Here is what I have so far based on how Magento joined sales/order_item and sales/order, but my join is not working for some reason :(

This is inside: Mage_Sales_Model_Resource_Report_Order_Createdat

$adapter $this->_getWriteAdapter();
...
$select $adapter->select();
$selectOrderGrid $adapter->select();
...
$gridCols = array(
   
'entry_id' => 'entry_id',
   
'order_channelname' => 'order_channelname'
);

$selectOrderGrid->from($this->getTable('sales/order_grid'), $gridCols)
   ->
group('entry_id');

$select->from(array('o' => $this->getTable('sales/order')))
   ->
join(array('og' => $selectOrderGrid), 'og.entry_id = o.entity_id', array())
   ->
where('o.state NOT IN (?)', array(
      
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
      
Mage_Sales_Model_Order::STATE_NEW
));
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top