The problem
In a Magento collection you are not allowed to have multiple items with the same id.
This happens when your result set of the database query returns the same item multiple times, most likely because you join a table which contains the same item twice or more.
I would assume that both of these tables contain the same product multiple times:
$collection->getSelect()->join('catalog_product_index_price as price_index', 'e.entity_id = price_index.entity_id');
$collection->getSelect()->join('catalog_product_entity_tier_price as tier', 'price_index.entity_id = tier.entity_id');
solution
- rewrite the code, so that the query result does not contain multiple items
- GROUP BY (doesn't return most of the time what you want without tinkering)
- use DISTINCT (doesn't work most of the time)
Ideas how to resolve (after comment)
I would assume, that the multiples only differ by qty, so in theory you could filter by qty, something like qty = 10
OR if it is different something like:
qty = (SELECT MIN(qty) FROM catalog_product_entity_tier_price jtp
WHERE jtp.entity_id = main_table.entity_id)