Adapter/PlentymarketsAdapter/ResponseParser/Product/Variation/VariationResponseParser.php
private function getVariationProperties(array $variation)
    {
        static $attributes;

        $result = [];
        foreach ((array) $variation['variationAttributeValues'] as $attributeValue) {
            if (!isset($attributes[$attributeValue['attributeId']])) {
                $attributes[$attributeValue['attributeId']] = $this->itemAttributesApi->findOne($attributeValue['attributeId']);
            }

            $values = $attributes[$attributeValue['attributeId']]['values'];

            $attributes[$attributeValue['attributeId']]['values'] = [];

            foreach ((array) $values as $value) {
                $attributes[$attributeValue['attributeId']]['values'][$value['id']] = $value;
            }

            if (!isset($attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['valueNames'])) {
                continue;
            }

            $propertyNames = $attributes[$attributeValue['attributeId']]['attributeNames'];
            $propertyPosition = $attributes[$attributeValue['attributeId']]['position'];
            $valueNames = $attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['valueNames'];
            $valuePosition = $attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['position'];

            $value = Value::fromArray([
                'value' => $valueNames[0]['name'],
                'position' => $valuePosition,
                'translations' => $this->getVariationPropertyValueTranslations($valueNames),
            ]);

            $result[] = Property::fromArray([
                'name' => $propertyNames[0]['name'],
                'position' => $propertyPosition,
                'values' => [$value],
                'translations' => $this->getVariationPropertyTranslations($propertyNames),
            ]);
        }

        return $result;
    }
private function getVariationProperties(array $variation)
    {
        static $attributes;

        $result = [];
        foreach ((array) $variation['variationAttributeValues'] as $attributeValue) {
            if (!isset($attributes[$attributeValue['attributeId']])) {
                $attributes[$attributeValue['attributeId']] = $this->itemAttributesApi->findOne($attributeValue['attributeId']);
            }

            $values = $attributes[$attributeValue['attributeId']]['values'];

            $attributes[$attributeValue['attributeId']]['values'] = [];

            foreach ((array) $values as $value) {
                $attributes[$attributeValue['attributeId']]['values'][$value['id']] = $value;
            }

            if (!isset($attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['valueNames'])) {
                continue;
            }

            $propertyNames = $attributes[$attributeValue['attributeId']]['attributeNames'];
            $propertyPosition = $attributes[$attributeValue['attributeId']]['position'];
            $valueNames = $attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['valueNames'];
            $valuePosition = $attributes[$attributeValue['attributeId']]['values'][$attributeValue['valueId']]['position'];

            $value = Value::fromArray([
                'value' => $valueNames[0]['name'],
                'position' => $valuePosition,
                'translations' => $this->getVariationPropertyValueTranslations($valueNames),
            ]);

            $result[] = Property::fromArray([
                'name' => $propertyNames[0]['name'],
                'position' => $propertyPosition,
                'values' => [$value],
                'translations' => $this->getVariationPropertyTranslations($propertyNames),
            ]);
        }

        return $result;
    }
private function getVariationProperties ( array $ variation ) { static $ attributes ; $ result = [ ] ; foreach ( ( array ) $ variation [ 'variationAttributeValues' ] as $ attributeValue ) { if ( ! isset ( $ attributes [ $ attributeValue [ 'attributeId' ] ] ) ) { $ attributes [ $ attributeValue [ 'attributeId' ] ] = $ this -> itemAttributesApi -> findOne ( $ attributeValue [ 'attributeId' ] ) ; } $ values = $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] ; $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] = [ ] ; foreach ( ( array ) $ values as $ value ) { $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] [ $ value [ 'id' ] ] = $ value ; } if ( ! isset ( $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] [ $ attributeValue [ 'valueId' ] ] [ 'valueNames' ] ) ) { continue ; } $ propertyNames = $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'attributeNames' ] ; $ propertyPosition = $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'position' ] ; $ valueNames = $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] [ $ attributeValue [ 'valueId' ] ] [ 'valueNames' ] ; $ valuePosition = $ attributes [ $ attributeValue [ 'attributeId' ] ] [ 'values' ] [ $ attributeValue [ 'valueId' ] ] [ 'position' ] ; $ value = Value :: fromArray ( [ 'value' => $ valueNames [ 0 ] [ 'name' ] , 'position' => $ valuePosition , 'translations' => $ this -> getVariationPropertyValueTranslations ( $ valueNames ) , ] ) ; $ result [ ] = Property :: fromArray ( [ 'name' => $ propertyNames [ 0 ] [ 'name' ] , 'position' => $ propertyPosition , 'values' => [ $ value ] , 'translations' => $ this -> getVariationPropertyTranslations ( $ propertyNames ) , ] ) ; } return $ result ; }
@param array $variation

@return Property[]
@param array $variation