diff --git a/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php b/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php index 3ff1c34d8486..995e274951b7 100644 --- a/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php +++ b/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php @@ -1,7 +1,7 @@ helper = $helper; @@ -114,6 +117,8 @@ public function __construct( ??ObjectManager::getInstance()->get(ScopeConfigInterface::class); $this->customerGroupFilter = $customerGroupFilter ?: ObjectManager::getInstance()->get(CustomerGroupFilter::class); + $this->processManager = $this->processManager + ?: ObjectManager::getInstance()->get(ProcessManager::class); } /** @@ -128,25 +133,38 @@ public function execute(array $entityIds = [], $useIndexTempTable = false) if ($entityIds) { $this->entityIds = $entityIds; $this->useIndexTempTable = $useIndexTempTable; - $this->connection->beginTransaction(); - try { - if ($this->customerGroupFilter->getGroupIds()) { - $this->customerGroupIds = $this->customerGroupFilter->getGroupIds(); - $this->removeIndexDataByCustomerGroupIds($this->customerGroupIds); - } else { - $this->removeObsoleteIndexData(); + if ($this->processManager->isMultiThreadsExecute()) { + $this->processRows(); + } else { + $this->connection->beginTransaction(); + try { + $this->processRows(); + $this->connection->commit(); + } catch (\Exception $exception) { + $this->connection->rollBack(); + throw $exception; } - $this->reindex(); - $this->connection->commit(); - } catch (\Exception $exception) { - $this->connection->rollBack(); - throw $exception; } } - $this->cleanCache(); } + /** + * Prepare data and reindex rows + * + * @return void + */ + private function processRows(): void + { + if ($this->customerGroupFilter->getGroupIds()) { + $this->customerGroupIds = $this->customerGroupFilter->getGroupIds(); + $this->removeIndexDataByCustomerGroupIds($this->customerGroupIds); + } else { + $this->removeObsoleteIndexData(); + } + $this->reindex(); + } + /** * Remove index entries before reindexation *