src/Shell/ImportShell.php
protected function _prepareData(Import $import, array $headers, array $data) : array
    {
        $result = [];

        $options = $import->get('options');

        $flipped = array_flip($headers);

        foreach ($options['fields'] as $field => $params) {
            if (empty($params['column']) && empty($params['default'])) {
                continue;
            }

            if (array_key_exists($params['column'], $flipped)) {
                $value = $data[$flipped[$params['column']]];
                if (!empty($value)) {
                    $result[$field] = $value;
                    continue;
                }
            }

            if (!empty($params['default'])) {
                $result[$field] = $params['default'];
            }
        }

        return $result;
    }
protected function _prepareData(Import $import, array $headers, array $data) : array
    {
        $result = [];

        $options = $import->get('options');

        $flipped = array_flip($headers);

        foreach ($options['fields'] as $field => $params) {
            if (empty($params['column']) && empty($params['default'])) {
                continue;
            }

            if (array_key_exists($params['column'], $flipped)) {
                $value = $data[$flipped[$params['column']]];
                if (!empty($value)) {
                    $result[$field] = $value;
                    continue;
                }
            }

            if (!empty($params['default'])) {
                $result[$field] = $params['default'];
            }
        }

        return $result;
    }
protected function _prepareData ( Import $ import , array $ headers , array $ data ) : array { $ result = [ ] ; $ options = $ import -> get ( 'options' ) ; $ flipped = array_flip ( $ headers ) ; foreach ( $ options [ 'fields' ] as $ field => $ params ) { if ( empty ( $ params [ 'column' ] ) && empty ( $ params [ 'default' ] ) ) { continue ; } if ( array_key_exists ( $ params [ 'column' ] , $ flipped ) ) { $ value = $ data [ $ flipped [ $ params [ 'column' ] ] ] ; if ( ! empty ( $ value ) ) { $ result [ $ field ] = $ value ; continue ; } } if ( ! empty ( $ params [ 'default' ] ) ) { $ result [ $ field ] = $ params [ 'default' ] ; } } return $ result ; }
Prepare row data.

@param \CsvMigrations\Model\Entity\Import $import Import entity
@param string[] $headers Upload file headers
@param mixed[] $data Row data
@return mixed[]
Prepare row data .