Import field collection using feeds (And example use case)
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 has 3 fields:
field_isbn - ebook's ISBN (this is unique)
body - ebook's description
field_page_content - this is a "field collection"
You will need to create or import content for this content type first, before you can import the field collection data (you cannot import it in the same step).
The content type needs to have a unique field on it (in this example, it is the ISBN).
2) In the "field_page_content" field collection, there are 3 fields:
field_page_number - textfield for page number, 1,2,3,4, ..., 150,151 (this is unique)
field_page_image - an image field
field_page_audio - an file field which store audio info for current page.
In the data you are importing, these three fields need to be associated with the unique content item field from step 1 (in this case, the ISBN). Also, you need to have a unique field in your imported data (in this case, it is field_page_number).
3) Create an importer for "field_page_content" using the "Field collection feeds" module.
To do this, you will need to add an Importer from the Fields Importers page (admin/structure/feeds). There is general documentation on how to do this on: https://drupal.org/node/638804
In the Processor area, choose "Field collection processor".
Here is the configuration for "Processor" > "Field collection processor" > "Settings":
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, (this is used for mapping target "Host Entity GUID" -- here you need to type in the machine name of the unique field in your content type that is associated with the data you are importing)
Identifier field name : field_page_number, (this is used for mapping target "Identifier Field" -- here you need to type in the machine name of the field in your field collection that is unique for the individual imported item)
Here is the Mapping for "Processor" > "Field collection processor" > "Mapping":
isbn (csv column) : Host Entity GUID (this will go into the field you entered in "Host entity GUID" on the settings panel)
number (csv column) : Identifier Field (this will go into the field you entered in "Identifier field" on the settings panel)
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.
4) Import your field collection data.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion