I have a Feeds importer set up. In the mapping I have a CSV column called Internal Links mapped to a corresponding node reference field called "Internal Links (Node reference by node title) -- allow duplicate nodes" The node ref field is set up to be unlimited values and to be an autocomplete text field widget type.

I'm referencing the imported nodes by node title. So the CSV column contains the node titles of the nodes that reside in the Drupal site.

Importing this works when there's one value (one node title) in the CSV row. However when I have comma separated node titles these will not import into the node reference field even though I have the field set to accept multi value (unlimited) and also it's set to be an auto complete field widget.

How can I get this to work to bring in comma separated node titles from one CSV row? I tried using the Feeds Tamper module to add an EXPLODE plugin and to explode based on comma (,) string separator. But this does not seem to be helping. It still does not import multiples. In this case nothing imports and the field in Drupal remains blank.

I also tried using the Entity Reference field module along with a patch to make this field work with Feeds importers but that also does not work.

Any suggestions?

-Trevor

Comments

ambientdrup’s picture

So a bit more detail on this from additional testing:

1) If my CSV contains the following in terms of formatting:

Node Title 1, Node Title 2

Only Node Title 1 imports. Node Title 2 shows this error in the Feeds Importer result:

Node Title 2 does not match an existing node.

But that node does exist so it should be matching.

2) I've set up Feeds Tamper to explode based on a comma separated listing but I'm still only successful in getting the first Node Title imported into the Node Reference field.

-Trevor

johnv’s picture

Title: Node reference field imports not working correctly » Node reference Feeds mapper does not import multiple references

The new title reflects the issue better.

ambientdrup’s picture

Ok I've spent a good deal of time debugging this today and I've been able to make it work. I can now import multivalue node references using the References module via Feeds per this:

1) I made sure to install the dev version of the References module

2) I installed the dev version of the Feeds Tamper module

3) I installed the alpha4 stable version of Feeds

4) I determined that I can get the multivalue node reference in using pipes (as opposed to commas) as the separation in both the CSV file and in the Feed Tamper module configuration for the mapping; and then in the Feeds mapper we need to use the | as the separator. I've also determined that this import process using pipes will work via both PC or Mac (I was concerned that maybe the Mac was causing issues on the import).

5) Additionally if you have "" wrapping the array or the values in your CSV it does not work. This still appears to be a bug. But without the "" and just using the pipes works.

So the values in the CSV should be:

node1|node2|node3

I've also determined that the ID column header in the CSV that maps to the GUID needs to be lowercase id and also tweaked to be lowercase in the actual importer mapping. If it’s uppercase it throws an odd SLYK error in the CSV file if you try to open it in Excel and that could be causing issues during the import.

So if you follow those instructions above you should be able to make it work. Pipes seem to work best both in the CSV and via the Feeds Tamper configuration for your mapping.

Hope this helps!

Best-

Trevor

johnv’s picture

Title: Node reference Feeds mapper does not import multiple references » Node reference Feeds mapper: How to import multiple references
Version: 7.x-2.0 » 7.x-2.x-dev
Status: Active » Closed (works as designed)

Nice, thankx for this detailed report.

Anonymous’s picture

I ran into the same issue, but... my export was using NIDs and seperated them with ", " not "," after exploding I only got the first result imported.

I switched to "|", but it probably would have worked the same for "," seperation.
Imported and all links were succesfully restored.

nally’s picture

@Quibical

Could you explain your before vs. after a little better. What did you do to get it to work in your case?

Anonymous’s picture

Wow, this topic is some time ago, reading it back I guess the following happened:

I had one field containing multiple nid's which at first were seperated by a comma and space ", ".
When I imported those only the first of the references was imported.

EG. data in the field was "141, 142, 143" only 141 got imported as a reference.

Presumably somehow the seperator can't by set to ", ", probably it gets trimmed to "," therefor in the first attempt it will try to import "141"
" 142"
" 143"
Of which the latter 2 are not valid nid's thus skipping them.

I changed the field data to "141|142|143" and all three were imported as references.

litvinova_yana’s picture

Qubical,

Great!!! It worked even without changing commas to "|". I just removed spaces after commas and got multiple values in node reference field.
So in your example we can change data to ""141,142,143" instead of "141, 142, 143".

litvinova_yana’s picture

And one more!
In our CSV or XML (as in my case) we still can use spaces after comma like this: "141, 142, 143"
But for this to work we need to set a string separator in tamper like this: ",%s", which means that a space should be taken into account.

jatorresdev’s picture

# 9 worked for me, thank you very much.