Reputation: 7233
This is my query:
select * from sales_flat_order sfo join sales_flat_order_payment sfop on sfo.entity_id = sfop.parent_id and sfo.status = 'some status' and sfop.method = 'some method'
I tried to follow this the official tutorial (http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento), but did not manage to get it to work.
Any ideas how to do that?
Thanks!
Upvotes: 1
Views: 231
Reputation: 1365
This should work:
/** @var $orderCollection Mage_Sales_Model_Resource_Order_Collection */
$orderCollection = Mage::getResourceModel('sales/order_collection');
$orderCollection->join(array('p' => 'sales/order_payment'), 'main_table.entity_id=p.parent_id')
->addFieldToFilter('p.method', 'some method')
->addFieldToFilter('main_table.status', 'some status');
Upvotes: 1