/** * @param array $result * @param array $attribute * @param string $locale * @param string $scope * * @return array */ public function transform(array $result, array $attribute, $locale, $scope) { $attributeCode = $attribute['code']; $properties = $attribute['properties']; if (isset($properties['reference_data_name']) && '' !== $properties['reference_data_name']) { $normalizedData = $result['normalizedData']; $fieldCode = ProductQueryUtility::getNormalizedValueField($attributeCode, $attribute['localizable'], $attribute['scopable'], $locale, $scope); $backendType = $attribute['backendType']; $references = isset($normalizedData[$fieldCode]) ? $normalizedData[$fieldCode] : []; if (AbstractAttributeType::BACKEND_TYPE_REF_DATA_OPTION === $backendType) { $references = $this->filterOptionValues($references, $locale); } else { foreach ($references as $indexReference => $reference) { $references[$indexReference] = $this->filterOptionValues($reference, $locale); } } $result[$attributeCode][$attribute['properties']['reference_data_name']] = $references; } return $result[$attributeCode]; }
/** * @param array $result * @param array $attribute * @param string $locale * @param string $scope * * @return array */ public function transform(array $result, array $attribute, $locale, $scope) { $attributeCode = $attribute['code']; $normalizedData = $result['normalizedData']; $fromNormData = array('pim_catalog_simpleselect', 'pim_catalog_multiselect'); if (in_array($attribute['attributeType'], $fromNormData)) { $fieldCode = ProductQueryUtility::getNormalizedValueField($attributeCode, $attribute['localizable'], $attribute['scopable'], $locale, $scope); $backendType = $attribute['backendType']; $options = isset($normalizedData[$fieldCode]) ? $normalizedData[$fieldCode] : []; if ($backendType === 'option') { $options = $this->filterOptionValues($options, $locale); } else { foreach ($options as $indexOption => $option) { $options[$indexOption] = $this->filterOptionValues($option, $locale); } } $result[$attributeCode][$backendType] = $options; } return $result[$attributeCode]; }