Skip to content

Commit f65a214

Browse files
committed
MC-38168: Manual Indexer after Merchandising - Empty Catalog/ Number of products incorrect
1 parent b7e0a7f commit f65a214

File tree

1 file changed

+12
-2
lines changed
  • app/code/Magento/Catalog/Model/Indexer/Product/Category/Action

1 file changed

+12
-2
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\Framework\DB\Adapter\AdapterInterface;
1919
use Magento\Framework\Indexer\IndexerRegistry;
2020
use Magento\Catalog\Model\Indexer\Category\Product as CategoryProductIndexer;
21+
use Magento\Indexer\Model\WorkingStateProvider;
2122

2223
/**
2324
* Category rows indexer.
@@ -48,6 +49,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
4849
*/
4950
private $indexerRegistry;
5051

52+
/**
53+
* @var WorkingStateProvider
54+
*/
55+
private $workingStateProvider;
56+
5157
/**
5258
* @param ResourceConnection $resource
5359
* @param StoreManagerInterface $storeManager
@@ -57,6 +63,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
5763
* @param CacheContext|null $cacheContext
5864
* @param EventManagerInterface|null $eventManager
5965
* @param IndexerRegistry|null $indexerRegistry
66+
* @param WorkingStateProvider|null $workingStateProvider
6067
*/
6168
public function __construct(
6269
ResourceConnection $resource,
@@ -66,12 +73,15 @@ public function __construct(
6673
MetadataPool $metadataPool = null,
6774
CacheContext $cacheContext = null,
6875
EventManagerInterface $eventManager = null,
69-
IndexerRegistry $indexerRegistry = null
76+
IndexerRegistry $indexerRegistry = null,
77+
?WorkingStateProvider $workingStateProvider = null
7078
) {
7179
parent::__construct($resource, $storeManager, $config, $queryGenerator, $metadataPool);
7280
$this->cacheContext = $cacheContext ?: ObjectManager::getInstance()->get(CacheContext::class);
7381
$this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(EventManagerInterface::class);
7482
$this->indexerRegistry = $indexerRegistry ?: ObjectManager::getInstance()->get(IndexerRegistry::class);
83+
$this->workingStateProvider = $workingStateProvider ?:
84+
ObjectManager::getInstance()->get(WorkingStateProvider::class);
7585
}
7686

7787
/**
@@ -90,7 +100,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
90100
$this->limitationByProducts = $idsToBeReIndexed;
91101
$this->useTempTable = $useTempTable;
92102
$indexer = $this->indexerRegistry->get(CategoryProductIndexer::INDEXER_ID);
93-
$workingState = $indexer->isWorking();
103+
$workingState = $this->workingStateProvider->isWorking($indexer->getId());
94104

95105
$affectedCategories = $this->getCategoryIdsFromIndex($idsToBeReIndexed);
96106

0 commit comments

Comments
 (0)