I am trying to import data into a Content type with Multifield, so far there is no support for this.
Take note, I am not trying to import into a "multi-value" field, but into a field created by the Multifield module.
Problem:
We are unable to import multifields data using feeds.
Solution:
The current solution requires a patch to feeds and other related feeds modules to be able to get a value returned when using {mapper}_feeds_get_target();
The patch needs help but the idea would be to submit data in the format:
Taxonomy Term Name,Simple On/Off checkbox,Simple On/Off checkbox,Textfield
"Term 1,0,0,Some other text|Term 2,1,1,Some other text here|Term 3,1,0,Some other text for term 3"
Comments
Comment #1
megachrizMappers for fields or properties provided by a contrib module, should go in that contrib module, so moving this issue to the Multifield issue queue.
Comment #2
boshtian commentedI also need this feature at the moment and will try to create .inc for multifield module.
The main question I see is whether to handle fields through the mapper of the subfields type, or to write own mapper, that will handle fields separately from the default behaviour.
I will dive into this and report back.
Comment #3
ryantollefson commentedI'm also looking for this.
Comment #4
JamesAn commentedI implemented this part of the way... but I'm getting stuck on the last portion of the import -- saving the mapped data to their respective (sub)field's data columns. Currently, I created a multifield_feeds_mapper module with the feeds.inc file defining targets for every relevant Multifield instance, all of their subfields, and all of the subfield's data columns.
If I understand this correctly, Multifield stores its subfields' values as their respective data columns named by a combination of the subfield name and column name.
I'll refactor this module into a patch for Multifield proper as I think it'd more appropriately reside directly in this module... two secs.
The last part -- I think it's a matter of saving the mapped data column values into Multifield in the presave hook afforded by Feeds. I'll give this a go today as well so I'll hopefully be more informed about how Multifield manages its data and how Feeds can hook into that setup.
Comment #5
arebacollins commentedLooking for the same. Is there a way of using ordinary fields in the place of multi fields for purposes of data import via feeds? or is there at least any known way of dumping data into a multifields field?
Comment #6
dobe commented@JamesAn could you provide a patch so we have a base to build from? Don't care if it is complete or if it works. It would be good to post here no matter.
Comment #7
dobe commentedThis patch is a start to create this functionality. It requires a patch to feeds (and most likely other related feeds mappers). The idea is simply to loop through and have the other feeds mappers generate the required values.
It is at least a start to the conversation.
It may be nice to create settings that you would apply similar to when a user can set guid to unique or taxonomy. I just didn't get there. These settings could help determine how the values get mapped.
Comment #8
dobe commentedComment #12
jbabiak commentedThe Patch in #7 was broken somehow, so I have rerolled it. No interdiff because I didn't make any changes to the code in the patch.
Comment #13
jbabiak commentedThis makes the multifield visible as a target for Feeds Mapper UI, but does not let me choose which field inside of the multifield to put data into.
Comment #14
dobe commentedYes your correct. I did not setup the per field configuration. However it does import the fields in the order they were added to multi-field. I have hard coded separators as well. It was mainly a patch so someone can help pick up the load.
Comment #15
david.qdoscc commentedThe only multifield issue relating to Rules integration was this one: #2499001: Can't load/edit multifield and subfields in Rules referring back to this thread.
If it is the same issue, will the work in this thread allow multifields to be used in Rules? It would be very useful to loop through multifield values and carry out actions with the subfields.
Comment #16
supriyarajgopal commentedHi everyone,
Please note that if you are applying the patch in #12, then the 'row weights' of the subfields of the multifield should begin with 0. I tried applying it but the fields were not getting mapped correctly. After analyzing the code for hours, I realized that the comparison is done with '[widget][weight]' against the '$values' array (& arrays always are indexed from 0).
Hope this helps someone.
P.S. dobe, thanx a lot for this patch! :)
Regards,
Supriya Rajgopal
Comment #17
xeniksp commentedHow should i pass the value in CSV ?
I have a multifield with two subfields one is entity id and the other is select list .
So if i want to pass 1 for entity and 1 for list how it should be correct to CSV.
When i try 1,1 or 1|1 i have the following error:
fatal error: Argument 5 passed to text_feeds_set_target() must be of the type array, none given.
Thanks in advance.
Comment #18
kris77 commentedIntegration with RULES?
With this patch https://www.drupal.org/files/issues/2041531-23-entity-api-support.patch Multifield is active in Rules but can't loop through multifield values and carry out actions with the subfields.
Thanks
Comment #19
anybodyThanks for the patch. It's a good starting point. Could someone please post an example how the CSV file should look like with multifield values?
Thank you very much in advance!
Comment #20
anybodyThe patch doesn't work anymore. In the latest version line 117 needs a mapping array as argument:
But even if that is fixed the patch doesn't work anymore because no values seem to be set.
Comment #21
anybodyOk I finally created a working solution. Patch attached. Furthermore I replaced the widget weight solution and replaced it by field counter. I think that's more safe as discussed in #16.
Comment #22
anybodyComment #23
jhodgdonI was hoping to find a Feeds solution to Mutlifield and saw this issue, so I took a look at this patch. It looks kind of reasonable, but it's not going to work for my use case.
The problem is that it's assuming that the data is coming in a string like this:
subfield1,subfield2,subfield3|subfield1,subfield2,subfield3|...
This might be OK if the input is CSV, and I may be able to coerce my parsed-XML input into this format, but I have a problem in that one of the subfields has text that may contain commas. So in this patch the string is first exploded on | and then on commas like this:
This is not going to work correctly if some of the values contain commas. Normally in CSV you can escape commas by putting a string in quotes, but this patch doesn't allow for it. So, it's too simplistic to work well for my use case.
Also, if you look at what some of the other *feeds_set_target() methods do in the Feeds module, you'll see that they expect the values to come in already as an array -- probably the CSV reader should be taking care of the separation into an array, not assuming this function in the patch should do it?
Hope that makes sense...
Comment #24
rickj commentedI've recently started using multifield for a project, and as I needed to some major importing, this patch is a great help.
However, it does have some shortcomings, in particular as noted by @jhodgdon, so I've done some work on it.
An updated patch is attached, this does the following:
I've imported over 1,000 items now without problem.