|
| 1 | +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 |
| 2 | +index 3ff1c34d8486..995e274951b7 100644 |
| 3 | +--- a/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php |
| 4 | ++++ b/vendor/magento/module-catalog-permissions/Model/Indexer/Category/Action/Rows.php |
| 5 | +@@ -1,7 +1,7 @@ |
| 6 | + <?php |
| 7 | + /** |
| 8 | +- * Copyright © Magento, Inc. All rights reserved. |
| 9 | +- * See COPYING.txt for license details. |
| 10 | ++ * Copyright 2014 Adobe |
| 11 | ++ * All Rights Reserved. |
| 12 | + */ |
| 13 | + namespace Magento\CatalogPermissions\Model\Indexer\Category\Action; |
| 14 | + |
| 15 | +@@ -17,6 +17,7 @@ |
| 16 | + use Magento\Framework\App\Config\ScopeConfigInterface; |
| 17 | + use Magento\Framework\App\ObjectManager; |
| 18 | + use Magento\Framework\DB\Query\Generator; |
| 19 | ++use Magento\Indexer\Model\ProcessManager; |
| 20 | + use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; |
| 21 | + use Magento\Store\Model\StoreManagerInterface; |
| 22 | + |
| 23 | +@@ -74,6 +75,7 @@ class Rows extends \Magento\CatalogPermissions\Model\Indexer\AbstractAction |
| 24 | + * @param ProductIndexFiller|null $productIndexFiller |
| 25 | + * @param TableMaintainer|null $tableMaintainer |
| 26 | + * @param ScopeConfigInterface|null $scopeConfig |
| 27 | ++ * @param ProcessManager|null $processManager |
| 28 | + * @throws \Exception |
| 29 | + * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
| 30 | + */ |
| 31 | +@@ -92,7 +94,8 @@ public function __construct( |
| 32 | + CustomerGroupFilter $customerGroupFilter = null, |
| 33 | + ProductIndexFiller $productIndexFiller = null, |
| 34 | + TableMaintainer $tableMaintainer = null, |
| 35 | +- ScopeConfigInterface $scopeConfig = null |
| 36 | ++ ScopeConfigInterface $scopeConfig = null, |
| 37 | ++ private ?ProcessManager $processManager = null |
| 38 | + ) { |
| 39 | + parent::__construct( |
| 40 | + $resource, |
| 41 | +@@ -106,7 +109,7 @@ public function __construct( |
| 42 | + $batchQueryGenerator, |
| 43 | + $productSelectDataProvider, |
| 44 | + $productIndexFiller, |
| 45 | +- null, |
| 46 | ++ $processManager, |
| 47 | + $tableMaintainer |
| 48 | + ); |
| 49 | + $this->helper = $helper; |
| 50 | +@@ -114,6 +117,8 @@ public function __construct( |
| 51 | + ??ObjectManager::getInstance()->get(ScopeConfigInterface::class); |
| 52 | + $this->customerGroupFilter = $customerGroupFilter |
| 53 | + ?: ObjectManager::getInstance()->get(CustomerGroupFilter::class); |
| 54 | ++ $this->processManager = $this->processManager |
| 55 | ++ ?: ObjectManager::getInstance()->get(ProcessManager::class); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | +@@ -128,25 +133,38 @@ public function execute(array $entityIds = [], $useIndexTempTable = false) |
| 60 | + if ($entityIds) { |
| 61 | + $this->entityIds = $entityIds; |
| 62 | + $this->useIndexTempTable = $useIndexTempTable; |
| 63 | +- $this->connection->beginTransaction(); |
| 64 | +- try { |
| 65 | +- if ($this->customerGroupFilter->getGroupIds()) { |
| 66 | +- $this->customerGroupIds = $this->customerGroupFilter->getGroupIds(); |
| 67 | +- $this->removeIndexDataByCustomerGroupIds($this->customerGroupIds); |
| 68 | +- } else { |
| 69 | +- $this->removeObsoleteIndexData(); |
| 70 | ++ if ($this->processManager->isMultiThreadsExecute()) { |
| 71 | ++ $this->processRows(); |
| 72 | ++ } else { |
| 73 | ++ $this->connection->beginTransaction(); |
| 74 | ++ try { |
| 75 | ++ $this->processRows(); |
| 76 | ++ $this->connection->commit(); |
| 77 | ++ } catch (\Exception $exception) { |
| 78 | ++ $this->connection->rollBack(); |
| 79 | ++ throw $exception; |
| 80 | + } |
| 81 | +- $this->reindex(); |
| 82 | +- $this->connection->commit(); |
| 83 | +- } catch (\Exception $exception) { |
| 84 | +- $this->connection->rollBack(); |
| 85 | +- throw $exception; |
| 86 | + } |
| 87 | + } |
| 88 | +- |
| 89 | + $this->cleanCache(); |
| 90 | + } |
| 91 | + |
| 92 | ++ /** |
| 93 | ++ * Prepare data and reindex rows |
| 94 | ++ * |
| 95 | ++ * @return void |
| 96 | ++ */ |
| 97 | ++ private function processRows(): void |
| 98 | ++ { |
| 99 | ++ if ($this->customerGroupFilter->getGroupIds()) { |
| 100 | ++ $this->customerGroupIds = $this->customerGroupFilter->getGroupIds(); |
| 101 | ++ $this->removeIndexDataByCustomerGroupIds($this->customerGroupIds); |
| 102 | ++ } else { |
| 103 | ++ $this->removeObsoleteIndexData(); |
| 104 | ++ } |
| 105 | ++ $this->reindex(); |
| 106 | ++ } |
| 107 | ++ |
| 108 | + /** |
| 109 | + * Remove index entries before reindexation |
| 110 | + * |
0 commit comments