Data Feed Manager problem
There is an open Data Feed Manager problem issue open, which may confuses Magento 2 developers. I solved this issue by a small change (or bugfix) in Magento Core, which should be in one for next version updates. I know core changes are bad, but for this it was the only solution and it comes directly from GitHub Magento 2 issues.
Data Feed Manager problem
If you generate a data feed, a strange error message appears: “Item (Magento\Catalog\Model\Product\Interceptor) with the same ID # already exists“. If you now check you products you may discover, that mentioned product id does not exists. What?
Solution
The sorce for this problem is a bug in vendor/magento/framework/Data/Collection.php. Go to line 406 and replace the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public function addItem(\Magento\Framework\DataObject $item) { $itemId = $this->_getItemId($item); if ($itemId !== null) { if (isset($this->_items[$itemId])) { throw new \Exception( 'Item (' . get_class($item) . ') with the same ID "' . $item->getId() . '" already exists.' ); } $this->_items[$itemId] = $item; } else { $this->_addItem($item); } return $this; } |
with this one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public function addItem(\Magento\Framework\DataObject $item) { $itemId = $this->_getItemId($item); if ($itemId !== null) { if (isset($this->_items[$itemId])) { return $this; } $this->_items[$itemId] = $item; } else { $this->_addItem($item); } return $this; } |
As you can see, this fix replaces a throw exception with return $this. Save this file and try to generate your data feed again. Now you should get a valid data feed with all needed products, but without this error message.
Data feed manager
Magento 2 offers you a built in tool to create your data feeds (for example for Google shopping). This tool is extremely useful, because in Magento 1 you had to buy commercial extensions to get the same functionality. As developer, it is recommended to use this tool instead of third party solutions.
Conclusion
I hope this Magento data feed manager problem bugfix will soon be released. It costs me many hours to find this problem. Based on the strange error message and wront product id it is nearly impossible to find the correct source of it.
Was this post useful for you? Please comment or share it.