Download & Extend

Cannot import multiple-valued field if spread out over multiple columns

Project:Node import
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

I have a field that has multiple values, but comes from multiple columns. So instead of having, for example:

A||B||C

in one column, I have three columns that has values A, B, and C respectively.

In some cases the content of the columns are empty, and that means that subsequent columns do not get imported. For example, if I have the first two columns blank, and the last column set to 'C', 'C' never gets imported.

I found the problem--in that the array with the data gets filtered. But the indices for that array remain the same. But when the data gets transferred from 'cck:fieldname:value' in $values into 'fieldname' for node import, it references the indices based on the number of items, not the actual array keys.

In node_import.inc I see the input value array gets culled twice-- I don't know if that is on purpose (line 637, and 678). In any case, I re-index the array. Included is a patch for testing.

AttachmentSize
node_import.patch591 bytes

Comments

#1

I just spent 16+ hours trying to track down a solution to this exact problem. I didn't realise the circumstances that triggered it, until just now. I'm astounded that this issue has not been a problem to others before us.

I, too have multiple fields that receive values from multiple columns in the CSV file, but I couldn't figure out why the values appeared in the nodes so randomly. It turns out it had to do with empty fields in the CSV columns!

I have tested the patch on two seperate installs and just now imported 60 nodes successfully to a custom content type with 6-7 cases of these multi-column data sources.

Thanks, legion80, for this (simple!) bug fix - it should go straight into CVS, IMO. Although, since I am not an experienced developer, and can't say that I fully understand the implications of this fix, I won't RTBC it.

Robrecht, you should be able to determine if there are any repercussions of this fix.

nobody click here