php – Magento加入不同的表
发布时间:2020-12-13 22:03:45 所属栏目:PHP教程 来源:网络整理
导读:我的Grid.php文件中有以下代码: function _prepareCollection () {$collection = Mage::getResourceModel($this-_getCollectionClass());$collection-getSelect()-joinLeft( array('sfog' = 'sales_flat_order_grid'),'main_table.entity_id = sfog.entity_
我的Grid.php文件中有以下代码:
function _prepareCollection () { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->joinLeft( array('sfog' => 'sales_flat_order_grid'),'main_table.entity_id = sfog.entity_id',array('sfog.shipping_name','sfog.billing_name') ); $collection->getSelect()->joinLeft( array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array( 'sfo.customer_email','sfo.weight','sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status','sfo.base_grand_total','sfo.grand_total' ) ); 我想添加表sales_order_item,但如果我添加此表,我会收到此错误: 具有相同id“119”的Item(Mage_Sales_Model_Order)已经存在 无论如何围绕这个? 解决方法
假设您加入soi意味着sales_order_item,请按soi.item_id分组
$collection->getSelect()->group('soi.item_id'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |