18
18
use Magento \Framework \DB \Adapter \AdapterInterface ;
19
19
use Magento \Framework \Indexer \IndexerRegistry ;
20
20
use Magento \Catalog \Model \Indexer \Category \Product as CategoryProductIndexer ;
21
+ use Magento \Indexer \Model \WorkingStateProvider ;
21
22
22
23
/**
23
24
* Category rows indexer.
@@ -48,6 +49,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
48
49
*/
49
50
private $ indexerRegistry ;
50
51
52
+ /**
53
+ * @var WorkingStateProvider
54
+ */
55
+ private $ workingStateProvider ;
56
+
51
57
/**
52
58
* @param ResourceConnection $resource
53
59
* @param StoreManagerInterface $storeManager
@@ -57,6 +63,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
57
63
* @param CacheContext|null $cacheContext
58
64
* @param EventManagerInterface|null $eventManager
59
65
* @param IndexerRegistry|null $indexerRegistry
66
+ * @param WorkingStateProvider|null $workingStateProvider
60
67
*/
61
68
public function __construct (
62
69
ResourceConnection $ resource ,
@@ -66,12 +73,15 @@ public function __construct(
66
73
MetadataPool $ metadataPool = null ,
67
74
CacheContext $ cacheContext = null ,
68
75
EventManagerInterface $ eventManager = null ,
69
- IndexerRegistry $ indexerRegistry = null
76
+ IndexerRegistry $ indexerRegistry = null ,
77
+ ?WorkingStateProvider $ workingStateProvider = null
70
78
) {
71
79
parent ::__construct ($ resource , $ storeManager , $ config , $ queryGenerator , $ metadataPool );
72
80
$ this ->cacheContext = $ cacheContext ?: ObjectManager::getInstance ()->get (CacheContext::class);
73
81
$ this ->eventManager = $ eventManager ?: ObjectManager::getInstance ()->get (EventManagerInterface::class);
74
82
$ this ->indexerRegistry = $ indexerRegistry ?: ObjectManager::getInstance ()->get (IndexerRegistry::class);
83
+ $ this ->workingStateProvider = $ workingStateProvider ?:
84
+ ObjectManager::getInstance ()->get (WorkingStateProvider::class);
75
85
}
76
86
77
87
/**
@@ -90,7 +100,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
90
100
$ this ->limitationByProducts = $ idsToBeReIndexed ;
91
101
$ this ->useTempTable = $ useTempTable ;
92
102
$ indexer = $ this ->indexerRegistry ->get (CategoryProductIndexer::INDEXER_ID );
93
- $ workingState = $ indexer -> isWorking ();
103
+ $ workingState = $ this -> workingStateProvider -> isWorking ($ indexer -> getId () );
94
104
95
105
$ affectedCategories = $ this ->getCategoryIdsFromIndex ($ idsToBeReIndexed );
96
106
0 commit comments