Magento加入两个集合
我需要从以下位置获取数据:Magento加入两个集合,magento,magento-1.x,Magento,Magento 1.x,我需要从以下位置获取数据: $collection = Mage::getResourceModel('sales/order_grid_collection') 我还需要从sales\u flat\u order表中获取state列值 如何联接这两个对象并获取数据?您需要向集合的select对象添加联接。在这种情况下,这是非常简单的,因为涉及的两个表(sales\u flat\u order\u grid和sales\u flat\u order)非常容易通过两个表共有的entity\u
$collection = Mage::getResourceModel('sales/order_grid_collection')
我还需要从sales\u flat\u order
表中获取state
列值
如何联接这两个对象并获取数据?您需要向集合的select对象添加联接。在这种情况下,这是非常简单的,因为涉及的两个表(
sales\u flat\u order\u grid
和sales\u flat\u order
)非常容易通过两个表共有的entity\u 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')
);
谢谢你,乔纳森。这太棒了。对我来说很好。如何使用在日期创建的订单过滤?