Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MappingItemConverter skips null fields #84

Closed
tpolman opened this issue Jun 18, 2014 · 1 comment
Closed

MappingItemConverter skips null fields #84

tpolman opened this issue Jun 18, 2014 · 1 comment

Comments

@tpolman
Copy link
Contributor

tpolman commented Jun 18, 2014

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!

@ddeboer
Copy link
Owner

ddeboer commented Jun 18, 2014

Ah, I recently fixed this issue in the workflow (0aeb02d) but apparently not here. Do you want to open a PR?

tpolman pushed a commit to tpolman/data-import that referenced this issue Jun 18, 2014
…rters not being applied to null values -- now also for mappingitemconverter)
@Baachi Baachi closed this as completed Jul 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants