12
12
use Magento \Store \Model \Store ;
13
13
14
14
/**
15
+ * Data provider class
16
+ *
15
17
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16
18
* @SuppressWarnings(PHPMD.TooManyFields)
17
19
* @api
@@ -570,8 +572,8 @@ public function prepareProductIndex($indexData, $productData, $storeId)
570
572
}
571
573
}
572
574
foreach ($ indexData as $ entityId => $ attributeData ) {
573
- foreach ($ attributeData as $ attributeId => $ attributeValue ) {
574
- $ value = $ this ->getAttributeValue ($ attributeId , $ attributeValue , $ storeId );
575
+ foreach ($ attributeData as $ attributeId => $ attributeValues ) {
576
+ $ value = $ this ->getAttributeValue ($ attributeId , $ attributeValues , $ storeId );
575
577
if (!empty ($ value )) {
576
578
if (isset ($ index [$ attributeId ])) {
577
579
$ index [$ attributeId ][$ entityId ] = $ value ;
@@ -602,16 +604,16 @@ public function prepareProductIndex($indexData, $productData, $storeId)
602
604
* Retrieve attribute source value for search
603
605
*
604
606
* @param int $attributeId
605
- * @param mixed $valueId
607
+ * @param mixed $valueIds
606
608
* @param int $storeId
607
609
* @return string
608
610
*/
609
- private function getAttributeValue ($ attributeId , $ valueId , $ storeId )
611
+ private function getAttributeValue ($ attributeId , $ valueIds , $ storeId )
610
612
{
611
613
$ attribute = $ this ->getSearchableAttribute ($ attributeId );
612
- $ value = $ this ->engine ->processAttributeValue ($ attribute , $ valueId );
614
+ $ value = $ this ->engine ->processAttributeValue ($ attribute , $ valueIds );
613
615
if (false !== $ value ) {
614
- $ optionValue = $ this ->getAttributeOptionValue ($ attributeId , $ valueId , $ storeId );
616
+ $ optionValue = $ this ->getAttributeOptionValue ($ attributeId , $ valueIds , $ storeId );
615
617
if (null === $ optionValue ) {
616
618
$ value = $ this ->filterAttributeValue ($ value );
617
619
} else {
@@ -626,13 +628,15 @@ private function getAttributeValue($attributeId, $valueId, $storeId)
626
628
* Get attribute option value
627
629
*
628
630
* @param int $attributeId
629
- * @param int $valueId
631
+ * @param int|string $valueIds
630
632
* @param int $storeId
631
633
* @return null|string
632
634
*/
633
- private function getAttributeOptionValue ($ attributeId , $ valueId , $ storeId )
635
+ private function getAttributeOptionValue ($ attributeId , $ valueIds , $ storeId )
634
636
{
635
637
$ optionKey = $ attributeId . '- ' . $ storeId ;
638
+ $ attributeValueIds = explode (', ' , $ valueIds );
639
+ $ attributeOptionValue = '' ;
636
640
if (!array_key_exists ($ optionKey , $ this ->attributeOptions )
637
641
) {
638
642
$ attribute = $ this ->getSearchableAttribute ($ attributeId );
@@ -650,8 +654,10 @@ private function getAttributeOptionValue($attributeId, $valueId, $storeId)
650
654
$ this ->attributeOptions [$ optionKey ] = null ;
651
655
}
652
656
}
653
-
654
- return $ this ->attributeOptions [$ optionKey ][$ valueId ] ?? null ;
657
+ foreach ($ attributeValueIds as $ attrValueId ) {
658
+ $ attributeOptionValue .= $ this ->attributeOptions [$ optionKey ][$ attrValueId ] . ' ' ;
659
+ }
660
+ return empty ($ attributeOptionValue ) ? null : trim ($ attributeOptionValue );
655
661
}
656
662
657
663
/**
0 commit comments