1
我在我的網格中有此代碼。我試圖從訂單和order_address中檢索一些字段。我得到了我的加入生成此SQL查詢:Magento加入錯誤
SELECT `main_table`.`region`, `main_table`.`city`, `order`.* FROM `sales_flat_order_address` AS `main_table` LEFT JOIN `` AS `order` ON order.entity_id = main_table.parent_id WHERE (address_type = 'shipping') AND (region = 'California') GROUP BY `city`
我可以在查詢中看到:LEFT JOIN '' AS 'order'
。這是不正確的。以下是查詢生成的代碼。歡迎任何幫助。
$collection = Mage::getModel('sales/order_address')->getCollection();
$collection
->addAttributeToSelect('region')
->addAttributeToSelect('city')
->addAttributeToFilter('address_type', 'shipping')
->addAttributeToFilter('region', 'California');
$collection->getSelect()->joinLeft(
array('order' => $this->getTable('sales/order')),//The problem is here!
'order.entity_id = main_table.parent_id',
array('order.*'))
->group('city');
對不起,但它沒有奏效。 – reydelleon