From a2da1c6cabd62671f3138b5e22228aa720638255 Mon Sep 17 00:00:00 2001 From: Dimosthenis Nikoudis Date: Fri, 21 Aug 2020 14:51:34 +0300 Subject: [PATCH] Properly translate select attributes in shop API --- .../Product/ProductAttributeValueViewFactory.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Factory/Product/ProductAttributeValueViewFactory.php b/src/Factory/Product/ProductAttributeValueViewFactory.php index 57c4a03b3..d2f5fffd4 100644 --- a/src/Factory/Product/ProductAttributeValueViewFactory.php +++ b/src/Factory/Product/ProductAttributeValueViewFactory.php @@ -40,6 +40,16 @@ public function create(ProductAttributeValueInterface $productAttributeValue, st $productAttributeTranslation = $productAttribute->getTranslation($localeCode); $productAttributeValueView->name = $productAttributeTranslation->getName(); + if ($productAttribute && $productAttribute->getType() === 'select') { + $configuration = $productAttribute->getConfiguration(); + $productAttributeValueView->value = array_map( + static function (string $value) use ($configuration, $locale) { + return $configuration['choices'][$value][$locale]; + }, + $productAttributeValueView->value + ); + } + return $productAttributeValueView; } }