@@ -272,9 +272,14 @@ private function prepareAttributeValues(
272
272
*/
273
273
private function prepareMultiselectValues (array $ values ): array
274
274
{
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
+ );
278
283
}
279
284
280
285
/**
@@ -305,9 +310,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
305
310
return $ attributeLabels ;
306
311
}
307
312
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 ();
311
316
}
312
317
}
313
318
@@ -324,7 +329,11 @@ private function getAttributeOptions(Attribute $attribute): array
324
329
{
325
330
if (!isset ($ this ->attributeOptionsCache [$ attribute ->getId ()])) {
326
331
$ 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 ;
328
337
}
329
338
330
339
return $ this ->attributeOptionsCache [$ attribute ->getId ()];
0 commit comments