@@ -272,9 +272,14 @@ private function prepareAttributeValues(
272272 */
273273 private function prepareMultiselectValues (array $ values ): array
274274 {
275- return \array_merge (...\array_map (function (string $ value ) {
276- return \explode (', ' , $ value );
277- }, $ values ));
275+ return \array_merge (
276+ ...\array_map (
277+ function (string $ value ) {
278+ return \explode (', ' , $ value );
279+ },
280+ $ values
281+ )
282+ );
278283 }
279284
280285 /**
@@ -305,9 +310,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
305310 return $ attributeLabels ;
306311 }
307312
308- foreach ($ options as $ option ) {
309- if (\in_array ( $ option -> getValue (), $ attributeValues )) {
310- $ attributeLabels [] = $ option ->getLabel ();
313+ foreach ($ attributeValues as $ attributeValue ) {
314+ if (isset ( $ options [ $ attributeValue ] )) {
315+ $ attributeLabels [] = $ options [ $ attributeValue ] ->getLabel ();
311316 }
312317 }
313318
@@ -324,7 +329,11 @@ private function getAttributeOptions(Attribute $attribute): array
324329 {
325330 if (!isset ($ this ->attributeOptionsCache [$ attribute ->getId ()])) {
326331 $ options = $ attribute ->getOptions () ?? [];
327- $ this ->attributeOptionsCache [$ attribute ->getId ()] = $ options ;
332+ $ optionsByValue = [];
333+ foreach ($ options as $ option ) {
334+ $ optionsByValue [$ option ->getValue ()] = $ option ;
335+ }
336+ $ this ->attributeOptionsCache [$ attribute ->getId ()] = $ optionsByValue ;
328337 }
329338
330339 return $ this ->attributeOptionsCache [$ attribute ->getId ()];
0 commit comments