Skip to content

Commit 45739ec

Browse files
committed
Revert "MAGE-1244: fix logic"
This reverts commit fe556cc.
1 parent fe556cc commit 45739ec

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

Model/Indexer/Category.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*/
1313
class Category implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1414
{
15-
public static $affectedProductIds = [];
16-
1715
public function __construct(
1816
protected StoreManagerInterface $storeManager,
1917
protected ConfigHelper $configHelper,
@@ -43,9 +41,6 @@ public function executeList(array $ids)
4341

4442
public function executeRow($id)
4543
{
46-
if (count(self::$affectedProductIds)) {
47-
$this->categoryBatchQueueProcessor->setAffectedProductIds(self::$affectedProductIds);
48-
}
4944
$this->execute([$id]);
5045
}
5146
}

Service/Category/BatchQueueProcessor.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
1212
use Algolia\AlgoliaSearch\Service\Category\IndexBuilder as CategoryIndexBuilder;
1313
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
14-
use Magento\Framework\Exception\LocalizedException;
1514
use Magento\Framework\Exception\NoSuchEntityException;
1615

1716
class BatchQueueProcessor implements BatchQueueProcessorInterface
1817
{
19-
public $affectedProductIds = [];
18+
public static $affectedProductIds = [];
2019

2120
public function __construct(
2221
protected Data $dataHelper,
@@ -30,7 +29,7 @@ public function __construct(
3029
* @param int $storeId
3130
* @param array|null $entityIds
3231
* @return void
33-
* @throws NoSuchEntityException|LocalizedException
32+
* @throws NoSuchEntityException
3433
*/
3534
public function processBatch(int $storeId, ?array $entityIds = null): void
3635
{
@@ -44,9 +43,7 @@ public function processBatch(int $storeId, ?array $entityIds = null): void
4443
return;
4544
}
4645

47-
if (count($this->affectedProductIds) > 0) {
48-
$this->rebuildAffectedProducts($storeId);
49-
}
46+
$this->rebuildAffectedProducts($storeId);
5047

5148
$categoriesPerPage = $this->configHelper->getNumberOfElementByPage();
5249

@@ -62,11 +59,14 @@ public function processBatch(int $storeId, ?array $entityIds = null): void
6259
/**
6360
* @param int $storeId
6461
*/
65-
protected function rebuildAffectedProducts(int $storeId): void
62+
protected function rebuildAffectedProducts($storeId)
6663
{
67-
if ($this->configHelper->indexProductOnCategoryProductsUpdate($storeId)) {
64+
$affectedProducts = self::$affectedProductIds;
65+
$affectedProductsCount = count($affectedProducts);
66+
67+
if ($affectedProductsCount > 0 && $this->configHelper->indexProductOnCategoryProductsUpdate($storeId)) {
6868
$productsPerPage = $this->configHelper->getNumberOfElementByPage();
69-
foreach (array_chunk($this->affectedProductIds, $productsPerPage) as $chunk) {
69+
foreach (array_chunk($affectedProducts, $productsPerPage) as $chunk) {
7070
/** @uses ProductIndexBuilder::buildIndexList() */
7171
$this->queue->addToQueue(
7272
ProductIndexBuilder::class,
@@ -86,7 +86,7 @@ protected function rebuildAffectedProducts(int $storeId): void
8686
* @param int $categoriesPerPage
8787
* @param int $storeId
8888
*/
89-
protected function processSpecificCategories(array $categoryIds, int $categoriesPerPage, int $storeId): void
89+
protected function processSpecificCategories($categoryIds, $categoriesPerPage, $storeId)
9090
{
9191
foreach (array_chunk($categoryIds, $categoriesPerPage) as $chunk) {
9292
/** @uses CategoryIndexBuilder::buildIndexList */
@@ -106,10 +106,10 @@ protected function processSpecificCategories(array $categoryIds, int $categories
106106
* @param int $storeId
107107
* @param int $categoriesPerPage
108108
*
109-
* @throws NoSuchEntityException
110-
* @throws LocalizedException
109+
* @throws Magento\Framework\Exception\LocalizedException
110+
* @throws Magento\Framework\Exception\NoSuchEntityException
111111
*/
112-
protected function processFullReindex(int $storeId, int $categoriesPerPage): void
112+
protected function processFullReindex($storeId, $categoriesPerPage)
113113
{
114114
/** @uses IndicesConfigurator::saveConfigurationToAlgolia() */
115115
$this->queue->addToQueue(IndicesConfigurator::class, 'saveConfigurationToAlgolia', ['storeId' => $storeId]);
@@ -138,13 +138,4 @@ protected function processFullReindex(int $storeId, int $categoriesPerPage): voi
138138
);
139139
}
140140
}
141-
142-
/**
143-
* @param array $affectedProductIds
144-
* @return void
145-
*/
146-
public function setAffectedProductIds(array $affectedProductIds): void
147-
{
148-
$this->affectedProductIds = $affectedProductIds;
149-
}
150141
}

0 commit comments

Comments
 (0)