5
5
*/
6
6
namespace Magento \CatalogSearch \Model \Indexer \Fulltext \Action ;
7
7
8
+ use Magento \CatalogSearch \Model \Indexer \Fulltext ;
9
+
8
10
/**
9
11
* @SuppressWarnings(PHPMD.TooManyFields)
10
12
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -99,9 +101,14 @@ class Full
99
101
protected $ storeManager ;
100
102
101
103
/**
102
- * @var \Magento\CatalogSearch\Model\Resource\EngineProvider
104
+ * @var \Magento\CatalogSearch\Model\Resource\Engine
103
105
*/
104
- protected $ engineProvider ;
106
+ protected $ engine ;
107
+
108
+ /**
109
+ * @var \Magento\Framework\IndexerInterface
110
+ */
111
+ protected $ indexHandler ;
105
112
106
113
/**
107
114
* @var \Magento\Framework\Stdlib\DateTime
@@ -146,6 +153,7 @@ class Full
146
153
* @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus
147
154
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory
148
155
* @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider
156
+ * @param \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory
149
157
* @param \Magento\Framework\Event\ManagerInterface $eventManager
150
158
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
151
159
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -154,6 +162,7 @@ class Full
154
162
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
155
163
* @param \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource
156
164
* @param \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory
165
+ * @param \Magento\Indexer\Model\ConfigInterface $indexerConfig
157
166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
158
167
*/
159
168
public function __construct (
@@ -164,14 +173,16 @@ public function __construct(
164
173
\Magento \Catalog \Model \Product \Attribute \Source \Status $ catalogProductStatus ,
165
174
\Magento \Catalog \Model \Resource \Product \Attribute \CollectionFactory $ productAttributeCollectionFactory ,
166
175
\Magento \CatalogSearch \Model \Resource \EngineProvider $ engineProvider ,
176
+ \Magento \CatalogSearch \Model \Indexer \IndexerHandlerFactory $ indexHandlerFactory ,
167
177
\Magento \Framework \Event \ManagerInterface $ eventManager ,
168
178
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
169
179
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
170
180
\Magento \Framework \Stdlib \DateTime $ dateTime ,
171
181
\Magento \Framework \Locale \ResolverInterface $ localeResolver ,
172
182
\Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
173
183
\Magento \CatalogSearch \Model \Resource \Fulltext $ fulltextResource ,
174
- \Magento \Framework \Search \Request \DimensionFactory $ dimensionFactory
184
+ \Magento \Framework \Search \Request \DimensionFactory $ dimensionFactory ,
185
+ \Magento \Indexer \Model \ConfigInterface $ indexerConfig
175
186
) {
176
187
$ this ->resource = $ resource ;
177
188
$ this ->catalogProductType = $ catalogProductType ;
@@ -182,7 +193,9 @@ public function __construct(
182
193
$ this ->eventManager = $ eventManager ;
183
194
$ this ->scopeConfig = $ scopeConfig ;
184
195
$ this ->storeManager = $ storeManager ;
185
- $ this ->engineProvider = $ engineProvider ;
196
+ $ this ->engine = $ engineProvider ->get ();
197
+ $ configData = $ indexerConfig ->getIndexer (Fulltext::INDEXER_ID );
198
+ $ this ->indexHandler = $ indexHandlerFactory ->create (['data ' => $ configData ]);
186
199
$ this ->dateTime = $ dateTime ;
187
200
$ this ->localeResolver = $ localeResolver ;
188
201
$ this ->localeDate = $ localeDate ;
@@ -245,11 +258,10 @@ protected function getWriteAdapter()
245
258
protected function rebuildIndex ($ productIds = null )
246
259
{
247
260
$ storeIds = array_keys ($ this ->storeManager ->getStores ());
248
- $ engine = $ this ->getEngineProvider ();
249
261
foreach ($ storeIds as $ storeId ) {
250
262
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
251
- $ engine ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
252
- $ engine ->saveIndex (
263
+ $ this -> indexHandler ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
264
+ $ this -> indexHandler ->saveIndex (
253
265
[$ dimension ],
254
266
$ this ->rebuildStoreIndex ($ storeId , $ productIds )
255
267
);
@@ -308,7 +320,7 @@ public function rebuildStoreIndex($storeId, $productIds = null)
308
320
$ visibility = $ this ->getSearchableAttribute ('visibility ' );
309
321
$ status = $ this ->getSearchableAttribute ('status ' );
310
322
$ statusIds = $ this ->catalogProductStatus ->getVisibleStatusIds ();
311
- $ allowedVisibility = $ this ->getEngineProvider () ->getAllowedVisibility ();
323
+ $ allowedVisibility = $ this ->engine ->getAllowedVisibility ();
312
324
313
325
$ lastProductId = 0 ;
314
326
while (true ) {
@@ -431,7 +443,7 @@ protected function getSearchableProducts(
431
443
protected function cleanIndex ($ storeId )
432
444
{
433
445
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
434
- $ this ->getEngineProvider () ->cleanIndex ([$ dimension ]);
446
+ $ this ->indexHandler ->cleanIndex ([$ dimension ]);
435
447
}
436
448
437
449
/**
@@ -444,7 +456,7 @@ protected function cleanIndex($storeId)
444
456
protected function deleteIndex ($ storeId = null , $ productIds = null )
445
457
{
446
458
$ dimension = $ this ->dimensionFactory ->create (['name ' => self ::SCOPE_FIELD_NAME , 'value ' => $ storeId ]);
447
- $ this ->getEngineProvider () ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
459
+ $ this ->indexHandler ->deleteIndex ([$ dimension ], $ this ->getIterator ($ productIds ));
448
460
}
449
461
450
462
/**
@@ -476,7 +488,7 @@ protected function getSearchableAttributes($backendType = null)
476
488
477
489
$ this ->eventManager ->dispatch (
478
490
'catelogsearch_searchable_attributes_load_after ' ,
479
- ['engine ' => $ this ->getEngineProvider () , 'attributes ' => $ attributes ]
491
+ ['engine ' => $ this ->engine , 'attributes ' => $ attributes ]
480
492
);
481
493
482
494
$ entity = $ this ->getEavConfig ()->getEntityType (\Magento \Catalog \Model \Product::ENTITY )->getEntity ();
@@ -722,7 +734,7 @@ protected function prepareProductIndex($indexData, $productData, $storeId)
722
734
$ index ['options ' ] = $ data ;
723
735
}
724
736
725
- return $ this ->getEngineProvider () ->prepareEntityIndex ($ index , $ this ->separator );
737
+ return $ this ->engine ->prepareEntityIndex ($ index , $ this ->separator );
726
738
}
727
739
728
740
/**
@@ -736,11 +748,11 @@ protected function prepareProductIndex($indexData, $productData, $storeId)
736
748
protected function getAttributeValue ($ attributeId , $ valueId , $ storeId )
737
749
{
738
750
$ attribute = $ this ->getSearchableAttribute ($ attributeId );
739
- $ value = $ this ->getEngineProvider () ->processAttributeValue ($ attribute , $ valueId );
751
+ $ value = $ this ->engine ->processAttributeValue ($ attribute , $ valueId );
740
752
741
753
if ($ attribute ->getIsSearchable ()
742
754
&& $ attribute ->usesSource ()
743
- && $ this ->getEngineProvider () ->allowAdvancedIndex ()
755
+ && $ this ->engine ->allowAdvancedIndex ()
744
756
) {
745
757
$ attribute ->setStoreId ($ storeId );
746
758
$ valueText = $ attribute ->getSource ()->getIndexOptionText ($ valueId );
@@ -803,12 +815,4 @@ protected function getIterator(array $data)
803
815
yield $ key => $ value ;
804
816
}
805
817
}
806
-
807
- /**
808
- * @return \Magento\CatalogSearch\Model\Resource\EngineInterface
809
- */
810
- private function getEngineProvider ()
811
- {
812
- return $ this ->engineProvider ->get ();
813
- }
814
818
}
0 commit comments