src/Observers/CatalogAttributeObserver.php
protected function prepareAttributes()
    {

        // load the recently created EAV attribute ID
        $attributeId = $this->getLastAttributeId();

        // initialize the attributes
        $attr = array(MemberNames::ATTRIBUTE_ID => $attributeId);

        // iterate over the possible columns and handle the data
        foreach ($this->columnNames as $columnName) {
            // query whether or not, the column is available in the CSV file
            if ($this->getSubject()->hasHeader($columnName)) {
                // custom handling for the additional_data column
                if ($columnName === ColumnKeys::ADDITIONAL_DATA) {
                    // load the raw additional data
                    $explodedAdditionalData = $this->getValue(ColumnKeys::ADDITIONAL_DATA, array(), array($this->getSubject(), 'explode'));

                    // query whether or not additional data has been set
                    if (sizeof($explodedAdditionalData) > 0) {
                        // load and extract the additional data
                        $additionalData = array();
                        foreach ($explodedAdditionalData as $value) {
                            list ($key, $val) = $this->getSubject()->explode($value, '=');
                            $additionalData[$key] = $val;
                        }

                        // set the additional data
                        $attr[$columnName] = $additionalData;

                        // query whether or not the attribute is a text or a visual swatch
                        if ($this->isSwatchType($additionalData)) {
                            // load the attribute option values for the custom store views
                            $attributeOptionValues = $this->getValue(ColumnKeys::ATTRIBUTE_OPTION_VALUES, array(), array($this, 'explode'));
                            $attributeOptionSwatch = $this->getSubject()->explode($this->getValue(ColumnKeys::ATTRIBUTE_OPTION_SWATCH), $this->getSubject()->getMultipleValueDelimiter());

                            // query whether or not the size of the option values equals the size of the swatch values
                            if (($sizeOfSwatchValues = sizeof($attributeOptionSwatch)) !== ($sizeOfOptionValues = sizeof($attributeOptionValues))) {
                                throw new \Exception(
                                    sprintf(
                                        'Size of option values "%d" doesn\'t equals size of swatch values "%d"',
                                        $sizeOfOptionValues,
                                        $sizeOfSwatchValues
                                    )
                                );
                            }
                        }
                    }
                } else {
                    // query whether or not a column contains a value
                    if ($this->hasValue($columnName)) {
                        $attr[$columnName] = $this->getValue($columnName);
                    }
                }
            }
        }

        // return the prepared product
        return $this->initializeEntity($attr);
    }
protected function prepareAttributes()
    {

        // load the recently created EAV attribute ID
        $attributeId = $this->getLastAttributeId();

        // initialize the attributes
        $attr = array(MemberNames::ATTRIBUTE_ID => $attributeId);

        // iterate over the possible columns and handle the data
        foreach ($this->columnNames as $columnName) {
            // query whether or not, the column is available in the CSV file
            if ($this->getSubject()->hasHeader($columnName)) {
                // custom handling for the additional_data column
                if ($columnName === ColumnKeys::ADDITIONAL_DATA) {
                    // load the raw additional data
                    $explodedAdditionalData = $this->getValue(ColumnKeys::ADDITIONAL_DATA, array(), array($this->getSubject(), 'explode'));

                    // query whether or not additional data has been set
                    if (sizeof($explodedAdditionalData) > 0) {
                        // load and extract the additional data
                        $additionalData = array();
                        foreach ($explodedAdditionalData as $value) {
                            list ($key, $val) = $this->getSubject()->explode($value, '=');
                            $additionalData[$key] = $val;
                        }

                        // set the additional data
                        $attr[$columnName] = $additionalData;

                        // query whether or not the attribute is a text or a visual swatch
                        if ($this->isSwatchType($additionalData)) {
                            // load the attribute option values for the custom store views
                            $attributeOptionValues = $this->getValue(ColumnKeys::ATTRIBUTE_OPTION_VALUES, array(), array($this, 'explode'));
                            $attributeOptionSwatch = $this->getSubject()->explode($this->getValue(ColumnKeys::ATTRIBUTE_OPTION_SWATCH), $this->getSubject()->getMultipleValueDelimiter());

                            // query whether or not the size of the option values equals the size of the swatch values
                            if (($sizeOfSwatchValues = sizeof($attributeOptionSwatch)) !== ($sizeOfOptionValues = sizeof($attributeOptionValues))) {
                                throw new \Exception(
                                    sprintf(
                                        'Size of option values "%d" doesn\'t equals size of swatch values "%d"',
                                        $sizeOfOptionValues,
                                        $sizeOfSwatchValues
                                    )
                                );
                            }
                        }
                    }
                } else {
                    // query whether or not a column contains a value
                    if ($this->hasValue($columnName)) {
                        $attr[$columnName] = $this->getValue($columnName);
                    }
                }
            }
        }

        // return the prepared product
        return $this->initializeEntity($attr);
    }
Prepare the attributes of the entity that has to be persisted.

@return array The prepared attributes
@throws \Exception Is thrown, if the size of the option values doesn't equals the size of swatch values, in case