Motivation

Drupal core supports multi value fields. In the past I've used Feeds Tamper to split single columns containing multiple values. In the future perhaps this is a more common use case.

TODO

Abstract this to other field types rather than just Entity Reference.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

twistor’s picture

Status: Needs work » Postponed

Hmm.. This is a tough one. The separator issue is problematic. We would have to specify an entire format, something like the CSV format, for how to specify fields that contain the separator. Example: thing a, "thing, b", thing c.

I think for now it's best left to feeds_tamper since it is so implementation specific.

Also, this really shouldn't be handled at the target level at all. This should be handled at the parser level. The targets shouldn't have to worry about any kind of formatting. They should just get an array of values and map them to field values. XML already has a way to set multiple values. What we could use is a way for the CSV parser to handle multiple values. That was frowned upon before, but I think is the correct approach.

opsdemon’s picture

Although this issue is a couple of years old now, I wanted to add an update as I've hit the same problem with the latest version of Feeds on D8.

When passing multiple tags with a CSV importer I expected to be able to enter a list of tags similar to what would be displayed in the UI. However, instead it simply treated the entire list as a single string and created a new term for it.

As a workaround I've used the patch from queenvictoria in EntityReference.php to add the new options and it seemed to work. (Thanks!)

Feeds Tamper is not an option as it's not available for D8.

As a permanent solution, I'd suggest adding an option to parse the content of a field as if it were a CSV value itself, with a delimiter. Surely if the rules around CSV parsing are robust enough to be used for the entire document then they could also be applied to individual fields too?

Anyway, it would be great if this could be looked at again as I believe a number of other people have encountered this issue too.

SpadXIII’s picture

FileSize
3.87 KB

Unfortunately the patch does not apply anymore to the latest version. Here's a re-roll of the patch against the dev version.

MegaChriz’s picture

@SpadXIII
To separate values into multiple, you can use Feeds Tamper's explode plugin, it has been ported now.

SpadXIII’s picture

FileSize
4.89 KB

Ah nice, I'll check it out!

I noticed a bug in the above patch, so attached a new one for anyone that does not want to use Feeds Tamper (as it does not have a release just yet)

SpadXIII’s picture

FileSize
4.43 KB

Rerolled the patch to apply against latest release. (feeds_tamper does not have a stable release just yet)

caspervoogt’s picture

#6 is working well for me. I had tried the latest release of feeds_tamper before this (and it does have a beta release now) but its Explode plugin was not working for me. Fortunately this does.

JAINV18’s picture

Hi @SPADXIII

I tried to apply the patch #6, but facing error "Referenced entity not found for field title with value 0." for entity reference fields with content types. Also, for multiple fields having multiple values this code fails.

Can you please help?

Thanks

SpadXIII’s picture

I haven't looked at this since I re-rolled the patch. So I don't think I can be of much help.

caspervoogt’s picture

#6 no longer applies for me.; I now get 'Could not apply patch! Skipping. The error was: Cannot apply patch'.

MegaChriz’s picture

@caspervoogt
I suggest to retry the Feeds Tamper plugin "Explode". The EntityReference target has indeed changed a lot in the past few years.

caspervoogt’s picture

Thanks @MegaChriz. I was just noting the #6 patch not applying so that other people don't try #6 and get frustrated :)

Feeds Tamper's explode plugin is indeed handy.