@@ -252,9 +252,14 @@ private function prepareAttributeValues(
252
252
*/
253
253
private function prepareMultiselectValues (array $ values ): array
254
254
{
255
- return \array_merge (...\array_map (function (string $ value ) {
256
- return \explode (', ' , $ value );
257
- }, $ values ));
255
+ return \array_merge (
256
+ ...\array_map (
257
+ function (string $ value ) {
258
+ return \explode (', ' , $ value );
259
+ },
260
+ $ values
261
+ )
262
+ );
258
263
}
259
264
260
265
/**
@@ -285,9 +290,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
285
290
return $ attributeLabels ;
286
291
}
287
292
288
- foreach ($ options as $ option ) {
289
- if (\in_array ( $ option -> getValue (), $ attributeValues )) {
290
- $ attributeLabels [] = $ option ->getLabel ();
293
+ foreach ($ attributeValues as $ attributeValue ) {
294
+ if (isset ( $ options [ $ attributeValue ] )) {
295
+ $ attributeLabels [] = $ options [ $ attributeValue ] ->getLabel ();
291
296
}
292
297
}
293
298
@@ -304,7 +309,11 @@ private function getAttributeOptions(Attribute $attribute): array
304
309
{
305
310
if (!isset ($ this ->attributeOptionsCache [$ attribute ->getId ()])) {
306
311
$ options = $ attribute ->getOptions () ?? [];
307
- $ this ->attributeOptionsCache [$ attribute ->getId ()] = $ options ;
312
+ $ optionsByValue = [];
313
+ foreach ($ options as $ option ) {
314
+ $ optionsByValue [$ option ->getValue ()] = $ option ;
315
+ }
316
+ $ this ->attributeOptionsCache [$ attribute ->getId ()] = $ optionsByValue ;
308
317
}
309
318
310
319
return $ this ->attributeOptionsCache [$ attribute ->getId ()];
0 commit comments