@@ -94,6 +94,11 @@ class DataProvider
94
94
*/
95
95
private $ metadata ;
96
96
97
+ /**
98
+ * @var array
99
+ */
100
+ private $ attributeOptions = [];
101
+
97
102
/**
98
103
* @param ResourceConnection $resource
99
104
* @param \Magento\Catalog\Model\Product\Type $catalogProductType
@@ -177,23 +182,13 @@ public function getSearchableProducts(
177
182
return $ result ;
178
183
}
179
184
180
- /**
181
- * Retrieve EAV Config Singleton
182
- *
183
- * @return \Magento\Eav\Model\Config
184
- */
185
- private function getEavConfig ()
186
- {
187
- return $ this ->eavConfig ;
188
- }
189
-
190
185
/**
191
186
* Retrieve searchable attributes
192
187
*
193
188
* @param string $backendType
194
189
* @return \Magento\Eav\Model\Entity\Attribute[]
195
190
*/
196
- private function getSearchableAttributes ($ backendType = null )
191
+ public function getSearchableAttributes ($ backendType = null )
197
192
{
198
193
if (null === $ this ->searchableAttributes ) {
199
194
$ this ->searchableAttributes = [];
@@ -210,7 +205,7 @@ private function getSearchableAttributes($backendType = null)
210
205
['engine ' => $ this ->engine , 'attributes ' => $ attributes ]
211
206
);
212
207
213
- $ entity = $ this ->getEavConfig () ->getEntityType (\Magento \Catalog \Model \Product::ENTITY )->getEntity ();
208
+ $ entity = $ this ->eavConfig ->getEntityType (\Magento \Catalog \Model \Product::ENTITY )->getEntity ();
214
209
215
210
foreach ($ attributes as $ attribute ) {
216
211
$ attribute ->setEntity ($ entity );
@@ -239,7 +234,7 @@ private function getSearchableAttributes($backendType = null)
239
234
* @param int|string $attribute
240
235
* @return \Magento\Eav\Model\Entity\Attribute
241
236
*/
242
- private function getSearchableAttribute ($ attribute )
237
+ public function getSearchableAttribute ($ attribute )
243
238
{
244
239
$ attributes = $ this ->getSearchableAttributes ();
245
240
if (is_numeric ($ attribute )) {
@@ -254,7 +249,7 @@ private function getSearchableAttribute($attribute)
254
249
}
255
250
}
256
251
257
- return $ this ->getEavConfig () ->getAttribute (\Magento \Catalog \Model \Product::ENTITY , $ attribute );
252
+ return $ this ->eavConfig ->getAttribute (\Magento \Catalog \Model \Product::ENTITY , $ attribute );
258
253
}
259
254
260
255
/**
@@ -487,11 +482,21 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
487
482
&& $ attribute ->usesSource ()
488
483
&& $ this ->engine ->allowAdvancedIndex ()
489
484
) {
490
- $ attribute ->setStoreId ($ storeId );
485
+ if (!isset ($ this ->attributeOptions [$ attributeId ][$ storeId ])) {
486
+ $ attribute ->setStoreId ($ storeId );
487
+ $ options = $ attribute ->getSource ()->toOptionArray ();
488
+ $ this ->attributeOptions [$ attributeId ][$ storeId ] = array_combine (
489
+ array_column ($ options , 'value ' ),
490
+ array_column ($ options , 'label ' )
491
+ );
492
+ }
491
493
492
- $ valueText = (array ) $ attribute ->getSource ()->getIndexOptionText ($ valueId );
494
+ $ valueText = '' ;
495
+ if (isset ($ this ->attributeOptions [$ attributeId ][$ storeId ][$ valueId ])) {
496
+ $ valueText = $ this ->attributeOptions [$ attributeId ][$ storeId ][$ valueId ];
497
+ }
493
498
494
- $ pieces = array_filter (array_merge ([$ value ], $ valueText ));
499
+ $ pieces = array_filter (array_merge ([$ value ], [ $ valueText] ));
495
500
496
501
$ value = implode ($ this ->separator , $ pieces );
497
502
}
0 commit comments