我需要从以下网址获取数据:
$collection = Mage::getResourceModel('sales/order_grid_collection')
另外,我需要从state
表格中获取sales_flat_order
列值。
如何加入这两个并获取数据?
答案 0 :(得分:0)
您需要为集合的select对象添加连接。在这种情况下,它非常直接,因为涉及的2个表(sales_flat_order_grid
和sales_flat_order
)很容易通过两个表共有的entity_id
列链接:
$collection = Mage::getResourceModel('sales/order_grid_collection');
$select = $collection->getSelect();
$resource = Mage::getSingleton('core/resource');
$select->join(
array('order' => $resource->getTableName('sales/order')),
'main_table.entity_id = order.entity_id',
array('state')
);