Community Documentation

Import field collection using feeds (And example use case)

Last updated November 12, 2012. Created by g089h515r806 on November 3, 2012.
Edited by dahacouk. Log in to edit this page.

You need install http://drupal.org/project/field_collection_feeds. Here is an example how to use it:
1,There is a content type "ebook", it include 3 fields:
field_isbn, ebook's ISBN, it is unique
body, ebook's description(introduction)
field_page_content, this is a "field collection" field.
2,In "field_page_content", there are 3 fields:
field_page_number, this field is unique in one ebook, for example, 1,2,3,4...150,151
field_page_image, an image field
field_page_audio, an file field which store audio info for current page.

3,Import "page content" through field collection feeds module. Here is my config in "Field collection processor"'s which settings page:

Update existing field collection item : Update existing field collection item
Field name : field_page_content
Host entity type : node
Is field : checked(TRUE), (it is used for mapping target "Host Entity GUID")
Field/property name of Host entity GUID : field_isbn, (it is used for mapping target "Host Entity GUID")
Identifier field name : field_page_number, (it is used for mapping target "Identifier Field")
4,Here is my mappings:
isbn (csv column): Host Entity GUID
number(csv column) : Identifier Field
number(csv column) : Page number(field_page_number)
image(csv column) : Page image(field_page_image)
audio(csv column) : Page audio(field_page_audio)

You must set "Host Entity GUID" and "Identifier Field" mappings.

Comments

How to update colloections ?

How to update colloections ?

after you set "Identifier

after you set "Identifier field name", you could update your field collection items.

Chinese drupal tutorials Think in Drupal

Would it be correct?

Perhaps i missed something, but it is not very clear to me:
Field/property name of Host entity GUID - Can it be node ID, title...? How can I make it use host node ID?
Identifier field name - What is it: field from CVS file? Some field in field collection? Some field in host node? Can it be field collection ID? How can i make it?

1,yes, it could be node id,

1,yes, it could be node id, title, you need set "is field" to FALSE.
2,A field in field collection item that is unique.

Chinese drupal tutorials Think in Drupal

Creating a Feed that can be imported

What is the best way to create a feed for this field collections parser? I have tried Views Data Export module. That seems to turn images fields and field collections into HTML when you choose XML file type and CSV file type formats the field collections incorrectly. Any thoughts?

Heya

i suspect i will try what you suggest and not open a brand new window. I agree it takes from the browsing experience. Many thank you for sharing your expertise. I just saved myself a large number of work and the consequence better. tui xach thoi trang

I get this error in feed logs

I get this error in feed logs SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1. Any idea what might be the problem ?

Same here

I'm getting the same error, and failed importing of field collection items.

I followed the instructions above, and am using XPath XML parser. Wonder if that could be the problem?

Need better instructions

Hi,

I'm running the latest version of Drupal, feeds, field-collection, and field-collection-feeds. However I'm having difficulty getting feeds to import my field collections.
Here's what I'm trying to do. I have three different field collections I will eventually want to import but they all have similar structures so I hope we can just get this first one working.

I have a content type "Departments".
It has a field collection field "Faculty"
"Faculty" contains several fields like any field collection such as..

  • Name
  • Status
  • Degree

Each "Faculty" field-collection is also "unlimited" and so each department will have several "Faculty" fields with different Delta's

I have followed the instructions above in an attempt to import the "Faculty" field to the "Department" nodes I currently have on my website.
Here are the settings I am using with Feeds Importer (I will start with Parser assuming the other settings are irrelevant. assume all settings at default unless otherwise indicated)

  1. CSV Parser (comma delimeted with headers. basically left to default)
  2. Processor: Field Collection Processor
  3. Field Collection Settings:
    • Update existing field collection item : Update existing field collection item
    • Field name : field_dep_faculty (machine name for field collection field)
    • Host entity type : node
    • Is field : checked(TRUE)
    • Field/property name of Host entity GUID : title (using the title of the node? I have also tried assigning a simple integer to each "Department" node with no success)
    • Identifier field name : field_dep_faculty_name (name field within faculty field collection. I'm not sure what to use for these last two. They are unique values but not always integers)

    Here are my mappings:
    hostid Host Entity GUID
    name Name
    namem Identifier Field
    status Status
    degree Degree

Please help me understand what settings I need to change. I've tried all sorts of variations with no luck importing the values. Also I am concerned about how to get the multiple values in with their delta values.

Thanks for the help!
gswebmaster

try with following

try with following config:
Update existing field collection item : Update existing field collection item
Field name : field_dep_faculty (machine name for field collection field)
Host entity type : node
Is field : checked(FALSE)
Field/property name of Host entity GUID : title (using the title of the node? I have also tried assigning a simple integer to each "Department" node with no success, title is a property.)
Identifier field name : field_dep_faculty_name (name field within faculty field collection. I'm not sure what to use for these last two. They are unique values but not always integers, )

Field/property name of Host entity GUID : a field or property that is unique in Host entity, use it to fetch Host entity.
Is field : whether it is a field or property. I need put this option after "Field/property name of Host entity GUID" instead of above it.
Identifier field name : it is field that unique in your field collection of one host entity

Chinese drupal tutorials Think in Drupal

Multiple data in Integer Field

I have a problem, not sure if this module can do it, so I'm asking.

I have a book store. field_genre (fiction, nonfiction, trailer etc...) If I make a text field, no problem, I can import using Feeds and my CSV file. But I can't filter by genre in Views, because it is a text field. If I use Integer:list, I can't feeds the data to the database from my CSV because it is not separating the genre for each field like you would with manually value...

I tried manually to add the values in the fields and then load the CSV, but that didn't work either.

It works for Year though (ie. for number)... Can anyone help or point to the right module (I tried Tamper, didn't seem to work).

Thanks,
Mario

Try it with feeds tamper

Try it with feeds tamper module.

Chinese drupal tutorials Think in Drupal

do u have an xmlrpc post for

do u have an xmlrpc post for create or update field-collection-item?

About this page

Drupal version
Drupal 7.x
Level
Beginner, Intermediate
Audience
Contributors, Programmers, Site administrators, Site builders

Develop for Drupal

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here