src/Observers/DynamicAttributeLoader.php
/**
     * Prepare the attributes of the entity that has to be persisted.
     *
     * Second parameter has  to be an associative array with the member name as key
     * and an array that contains the column name and the data's backend type, e. g.
     *
     * <code>array('min_qty => array('out_of_stock_qty', 'float'))</code>
     *
     * @param \TechDivision\Import\Observers\DynamicAttributeObserverInterface $observer The observer to load the attributes for
     * @param array                                                            $columns  The array with the possible columns to load the data from
     *
     * @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
     */
Prepare the attributes of the entity that has to be persisted.
Second parameter has  to be an associative array with the member name as key
and an array that contains the column name and the data's backend type, e. g.



@param \TechDivision\Import\Observers\DynamicAttributeObserverInterface $observer The observer to load the attributes for
@param array                                                            $columns  The array with the possible columns to load the data from

@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
Prepare the attributes of the entity that has to be persisted . Second parameter has to be an associative array with the member name as key and an array that contains the column name and the data ' s backend type e . g . @param \ TechDivision \ Import \ Observers \ DynamicAttributeObserverInterface $observer The observer to load the attributes for @param array $columns The array with the possible columns to load the data from @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
public function load(DynamicAttributeObserverInterface $observer, array $columns)
    {
        $attr = array();
        foreach ($columns as $memberName => $metadata) {
            list ($columnName, $backendType) = $metadata;
            if ($observer->hasHeader($columnName)) {
                if ($observer->hasValue($columnName)) {
                    $attr[$memberName] = $observer->castValueByBackendType($backendType, $observer->getValue($columnName));
                }
            }
        }
        return $attr;
    }
public function load ( DynamicAttributeObserverInterface $ observer , array $ columns ) { $ attr = array ( ) ; foreach ( $ columns as $ memberName => $ metadata ) { list ( $ columnName , $ backendType ) = $ metadata ; if ( $ observer -> hasHeader ( $ columnName ) ) { if ( $ observer -> hasValue ( $ columnName ) ) { $ attr [ $ memberName ] = $ observer -> castValueByBackendType ( $ backendType , $ observer -> getValue ( $ columnName ) ) ; } } } return $ attr ; }
Prepare the attributes of the entity that has to be persisted.
Prepare the attributes of the entity that has to be persisted .
// initialize the array for the attributes // iterate over the possible columns and handle the data // extract column name and backend type from the metadata // query whether or not, the column is available in the CSV file // query whether or not a column contains a value // return the prepared product