Normally, this is a bug in the data or in the collection implementation.
Here's a solution to a broader issue. This works on arbitrary collection, not only for Catalog_Model_Product
.
Step 1. Modify the core file lib/Varien/Data/Collection.php
, function addItem()
, but unlike this answer suggests, don't hide the error.
Instead, add extra error information to the exception thrown:
if (isset($this->_items[$itemId])) {
throw new Exception('Item ('.get_class($item).
') with the same id "'.$item->getId().'" already exist' .
'. SQL that caused this: ' . $this->getSelect());
}
Step 2. Take the offending query from your error report and run it by hand. See what records duplicate the collection key. Add order by <key field>
as needed.
Dissect the query removing the participating tables one-by-one, and see which record caused the duplication.
I believe this patch should be in the core.
group by
to get only unique product id. See magento.stackexchange.com/questions/12773/…