I have a Magento2.3.5 Version but that store is causing a strange issue Store is really fast when just Reindex is runned but after 2 or maybe 3 hrs it became really slow and I have to run Reindex again. So to Trace that issue I’ve checked System.log file which was showing
[2024-06-28 11:12:46] main.CRITICAL: Item (MagentoCatalogModelProductInterceptor) with the same ID "881" already exists. [] []
so for that I’ve created a plugin which code is
di.xml
<?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="MagentoEavModelEntityCollectionAbstractCollection">
<plugin name="find_duplicate_entry" type="TreezeeDuplicateEntrypluginCollection" sortOrder="20"/>
</type>
</config>
while the plugin code is
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
*/
namespace TreezeeDuplicateEntryplugin;
use MagentoFrameworkDataCollectionEntityFactoryInterface;
use MagentoFrameworkOptionArrayInterface;
class Collection
{
/**
* @param MagentoEavModelEntityCollectionAbstractCollection $subject
* @param Closure $process
* @param MagentoFrameworkDataObject $dataObject
* @return $this
*/
public function aroundAddItem(MagentoEavModelEntityCollectionAbstractCollection $subject, Closure $process, MagentoFrameworkDataObject $dataObject)
{
try{
return $process($dataObject);
}catch ( Exception $e){
return $this;
}
}
}
now this code fixes the above issue but still the Store Reindex issue was there so now when I looked at the System.log file the it shows
Now I dont know why this issue is happening or it is related to speed issue or not and how to fix that.. any help would be really appreciated Thanks.