コード例 #1
0
 /**
  * @param array $result
  * @param array $attribute
  * @param string $locale
  * @param string $scope
  *
  * @return array
  */
 protected function prepareMediaData(array $result, array $attribute, $locale, $scope)
 {
     $attributeCode = $attribute['code'];
     $backendType = $attribute['backendType'];
     $value = $result[$attributeCode];
     if (AttributeTypes::IMAGE === $attribute['attributeType'] && isset($value[$backendType])) {
         $normalizedData = $result['normalizedData'];
         $attributeCode = ProductQueryUtility::getNormalizedValueField($attributeCode, $attribute['localizable'], $attribute['scopable'], $locale, $scope);
         $value[$backendType] = $normalizedData[$attributeCode];
     }
     return $value;
 }
コード例 #2
0
 /**
  * @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 = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::OPTION_MULTI_SELECT];
     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];
 }
コード例 #3
0
 /**
  * @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 (AttributeTypes::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];
 }