1

这是我的查询:

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'

我尝试按照官方教程(http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento)进行操作,但未能使其正常工作。

任何想法如何做到这一点?

谢谢!

4

1 回答 1

1

这应该有效:

/** @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');
于 2013-02-25T18:10:01.847 回答