Php 具有相同id的项目(Mage“销售”型号“;429“;已经存在

Php 具有相同id的项目(Mage“销售”型号“;429“;已经存在,php,magento,Php,Magento,每当我将reports/quote_集合与sales/quote_item表合并时,就会出现此错误。我正在尝试为未注册用户创建一个废弃购物车报告。我需要展示废弃手推车中的所有物品 请参阅下面的代码: $this->addFieldToFilter('items_count', array('neq' => '0')) ->addFieldToFilter('main_table.is_active', '1') ->addSubtotal($store

每当我将reports/quote_集合与sales/quote_item表合并时,就会出现此错误。我正在尝试为未注册用户创建一个废弃购物车报告。我需要展示废弃手推车中的所有物品

请参阅下面的代码:

$this->addFieldToFilter('items_count', array('neq' => '0'))
     ->addFieldToFilter('main_table.is_active', '1')
     ->addSubtotal($storeIds, $filter)
     ->setOrder('updated_at');
$this->getSelect()->joinInner(
     array('quote_items' => $this->getTable('sales/quote_item')),
            'quote_items.quote_id = main_table.entity_id',
            'name');
if (is_array($storeIds) && !empty($storeIds)) {
     $this->addFieldToFilter('store_id', array('in' => $storeIds));
}

return $this;

如何解决此错误?是否有显示所有项目的方法?

当Magento两次尝试将同一项目添加到集合时,会出现此消息,因为JOIN查询结果多次包含该项目

您可以通过在主键上按以下方式分组来避免这种情况:

$collection->getSelect()->group('e.entity_id')

嗨,维克多!欢迎来到Stackoverflow。我建议你去,那边的人都很了解Magento!