When you get error like: Item (Magento\Catalog\Model\Product\Interceptor) with the same ID “<id>” already exists.
Then you can use below module to resolve above error.
1. Create new folders Magemonkey/DuplicateEntry in app/code magento folder.
2. add new file registration.php in DuplicateEntry folder and put below code.
1 2 3 4 5 6 7 |
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Magemonkey_DuplicateEntry', __DIR__ ); |
3. add new file etc/module.xml in DuplicateEntry folder and put below code.
1 2 3 4 5 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Magemonkey_DuplicateEntry" setup_version="1.0.1"></module> </config> |
4. add new file etc/di.xml in DuplicateEntry folder and put below code.
1 2 3 4 5 6 7 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Eav\Model\Entity\Collection\AbstractCollection"> <plugin name="find_duplicate_entry" type="Magemonkey\DuplicateEntry\plugin\Collection" sortOrder="20"/> </type> </config> |
5. add new file plugin/Collection.php in DuplicateEntry folder and put below code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php /** * Copyright © Magento, Inc. All rights reserved. */ namespace Magemonkey\DuplicateEntry\plugin; use Magento\Framework\Data\Collection\EntityFactoryInterface; use Magento\Framework\Option\ArrayInterface; class Collection { /** * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $subject * @param \Closure $process * @param \Magento\Framework\DataObject $dataObject * @return $this */ public function aroundAddItem(\Magento\Eav\Model\Entity\Collection\AbstractCollection $subject, \Closure $process, \Magento\Framework\DataObject $dataObject) { try{ return $process($dataObject); }catch ( \Exception $e){ return $this; } } } |
[crayon-63e091e09adb5861686661/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.