@@ -99,9 +99,14 @@ class Full
99
99
protected $ storeManager ;
100
100
101
101
/**
102
- * @var \Magento\CatalogSearch\Model\Resource\EngineProvider
102
+ * @var \Magento\CatalogSearch\Model\Resource\Engine
103
103
*/
104
- protected $ engineProvider ;
104
+ protected $ engine ;
105
+
106
+ /**
107
+ * @var \Magento\Framework\IndexerInterface
108
+ */
109
+ protected $ indexHandler ;
105
110
106
111
/**
107
112
* @var \Magento\Framework\Stdlib\DateTime
@@ -145,7 +150,8 @@ class Full
145
150
* @param \Magento\Framework\Search\Request\Config $searchRequestConfig
146
151
* @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus
147
152
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory
148
- * @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider
153
+ * @param \Magento\CatalogSearch\Model\Resource\Engine $engine
154
+ * @param \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory
149
155
* @param \Magento\Framework\Event\ManagerInterface $eventManager
150
156
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
151
157
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -163,7 +169,8 @@ public function __construct(
163
169
\Magento \Framework \Search \Request \Config $ searchRequestConfig ,
164
170
\Magento \Catalog \Model \Product \Attribute \Source \Status $ catalogProductStatus ,
165
171
\Magento \Catalog \Model \Resource \Product \Attribute \CollectionFactory $ productAttributeCollectionFactory ,
166
- \Magento \CatalogSearch \Model \Resource \EngineProvider $ engineProvider ,
172
+ \Magento \CatalogSearch \Model \Resource \Engine $ engine ,
173
+ \Magento \CatalogSearch \Model \Indexer \IndexerHandlerFactory $ indexHandlerFactory ,
167
174
\Magento \Framework \Event \ManagerInterface $ eventManager ,
168
175
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
169
176
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
@@ -182,7 +189,8 @@ public function __construct(
182
189
$ this ->eventManager = $ eventManager ;
183
190
$ this ->scopeConfig = $ scopeConfig ;
184
191
$ this ->storeManager = $ storeManager ;
185
- $ this ->engineProvider = $ engineProvider ;
192
+ $ this ->engine = $ engine ;
193
+ $ this ->indexHandler = $ indexHandlerFactory ->create ();
186
194
$ this ->dateTime = $ dateTime ;
187
195
$ this ->localeResolver = $ localeResolver ;
188
196
$ this ->localeDate = $ localeDate ;
@@ -245,11 +253,10 @@ protected function getWriteAdapter()
245
253
protected function rebuildIndex ($ productIds = null )
246
254
{
247
255
$ storeIds = array_keys ($ this ->storeManager ->getStores ());
248
- $ engine = $ this ->getEngineProvider ();
249
256
foreach ($ storeIds as $ storeId ) {
250
257
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
251
- $ engine ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
252
- $ engine ->saveIndex (
258
+ $ this -> indexHandler ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
259
+ $ this -> indexHandler ->saveIndex (
253
260
[$ dimension ],
254
261
$ this ->rebuildStoreIndex ($ storeId , $ productIds )
255
262
);
@@ -308,7 +315,7 @@ public function rebuildStoreIndex($storeId, $productIds = null)
308
315
$ visibility = $ this ->getSearchableAttribute ('visibility ' );
309
316
$ status = $ this ->getSearchableAttribute ('status ' );
310
317
$ statusIds = $ this ->catalogProductStatus ->getVisibleStatusIds ();
311
- $ allowedVisibility = $ this ->getEngineProvider () ->getAllowedVisibility ();
318
+ $ allowedVisibility = $ this ->engine ->getAllowedVisibility ();
312
319
313
320
$ lastProductId = 0 ;
314
321
while (true ) {
@@ -431,7 +438,7 @@ protected function getSearchableProducts(
431
438
protected function cleanIndex ($ storeId )
432
439
{
433
440
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
434
- $ this ->getEngineProvider () ->cleanIndex ([$ dimension ]);
441
+ $ this ->indexHandler ->cleanIndex ([$ dimension ]);
435
442
}
436
443
437
444
/**
@@ -444,7 +451,7 @@ protected function cleanIndex($storeId)
444
451
protected function deleteIndex ($ storeId = null , $ productIds = null )
445
452
{
446
453
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
447
- $ this ->getEngineProvider () ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
454
+ $ this ->indexHandler ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
448
455
}
449
456
450
457
/**
@@ -476,7 +483,7 @@ protected function getSearchableAttributes($backendType = null)
476
483
477
484
$ this ->eventManager ->dispatch (
478
485
'catelogsearch_searchable_attributes_load_after ' ,
479
- ['engine ' => $ this ->getEngineProvider () , 'attributes ' => $ attributes ]
486
+ ['engine ' => $ this ->engine , 'attributes ' => $ attributes ]
480
487
);
481
488
482
489
$ entity = $ this ->getEavConfig ()->getEntityType (\Magento \Catalog \Model \Product::ENTITY )->getEntity ();
@@ -722,7 +729,7 @@ protected function prepareProductIndex($indexData, $productData, $storeId)
722
729
$ index ['options ' ] = $ data ;
723
730
}
724
731
725
- return $ this ->getEngineProvider () ->prepareEntityIndex ($ index , $ this ->separator );
732
+ return $ this ->engine ->prepareEntityIndex ($ index , $ this ->separator );
726
733
}
727
734
728
735
/**
@@ -736,11 +743,11 @@ protected function prepareProductIndex($indexData, $productData, $storeId)
736
743
protected function getAttributeValue ($ attributeId , $ valueId , $ storeId )
737
744
{
738
745
$ attribute = $ this ->getSearchableAttribute ($ attributeId );
739
- $ value = $ this ->getEngineProvider () ->processAttributeValue ($ attribute , $ valueId );
746
+ $ value = $ this ->engine ->processAttributeValue ($ attribute , $ valueId );
740
747
741
748
if ($ attribute ->getIsSearchable ()
742
749
&& $ attribute ->usesSource ()
743
- && $ this ->getEngineProvider () ->allowAdvancedIndex ()
750
+ && $ this ->engine ->allowAdvancedIndex ()
744
751
) {
745
752
$ attribute ->setStoreId ($ storeId );
746
753
$ valueText = $ attribute ->getSource ()->getIndexOptionText ($ valueId );
@@ -803,12 +810,4 @@ protected function getIterator(array $data)
803
810
yield $ key => $ value ;
804
811
}
805
812
}
806
-
807
- /**
808
- * @return \Magento\CatalogSearch\Model\Resource\EngineInterface
809
- */
810
- private function getEngineProvider ()
811
- {
812
- return $ this ->engineProvider ->get ();
813
- }
814
813
}
0 commit comments