public function addValueData(AttributeInterface $attribute, $valueData, array $context = null)
    {
        $this->checkAttribute($attribute);
        if (!$attribute->isCollection()) {
            $m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'";
            throw new InvalidValueDataException($m);
        }
        $newValue = $this->createValue($attribute, $context);
        $position = -1;
        foreach ($this->getInternalValues($attribute, $context) as $value) {
            $position = max($position, $value->getPosition());
        }
        $newValue->setPosition($position + 1);
        $this->setInternalValueData($attribute, $newValue, $valueData);

        return $this;
    }
public function addValueData(AttributeInterface $attribute, $valueData, array $context = null)
    {
        $this->checkAttribute($attribute);
        if (!$attribute->isCollection()) {
            $m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'";
            throw new InvalidValueDataException($m);
        }
        $newValue = $this->createValue($attribute, $context);
        $position = -1;
        foreach ($this->getInternalValues($attribute, $context) as $value) {
            $position = max($position, $value->getPosition());
        }
        $newValue->setPosition($position + 1);
        $this->setInternalValueData($attribute, $newValue, $valueData);

        return $this;
    }
public function addValueData ( AttributeInterface $ attribute , $ valueData , array $ context = null ) { $ this -> checkAttribute ( $ attribute ) ; if ( ! $ attribute -> isCollection ( ) ) { $ m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'" ; throw new InvalidValueDataException ( $ m ) ; } $ newValue = $ this -> createValue ( $ attribute , $ context ) ; $ position = - 1 ; foreach ( $ this -> getInternalValues ( $ attribute , $ context ) as $ value ) { $ position = max ( $ position , $ value -> getPosition ( ) ) ; } $ newValue -> setPosition ( $ position + 1 ) ; $ this -> setInternalValueData ( $ attribute , $ newValue , $ valueData ) ; return $ this ; }
Append data to an attribute

@param AttributeInterface $attribute
@param mixed              $valueData
@param array|null         $context

@throws InvalidValueDataException
@throws MissingAttributeException
@throws ContextException

@return DataInterface
Append data to an attribute