Skip to content

MappingItemConverter skips null fields #84

@tpolman

Description

@tpolman

In Ddeboer\DataImport\ItemConverter\MappingItemConverter

    /**
     * Applies a mapping to an item
     *
     * @param array  $item
     * @param string $from
     * @param string $to
     *
     * @return array
     */
    protected function applyMapping(array $item, $from, $to)
    {
        // skip fields that dont exist
        if (!isset($item[$from])) {
            return $item;
        }

isset also skips fields which do exist but have a null value, this can be fixed by replacing the isset code (line 79) with:

if (!array_key_exists($from, $item)) { 

If you explicitly do not want to have null fields mapped then you could use another ItemConverter which filters empty keys. Or make it optional behaviour of MappingItemConverters.

Great bundle!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions