How to Import Feeds with Field Collections

  • henok_mikre

    Henok Mikre

If you Google "how to import feeds with field collections," you are most likely going to find resources on how to use Field collection feeds module. That module is very difficult to use and there is a much easier solution. There is a Field collection patch that adds Feeds integration.

We will use a dataset from the DC Open Data portal to test this. The Child Development Centers dataset is a list of centers provided by OSSE (Office of the State Superintendent of Education). It has "Name," "Address," "Zipcode" and geocode information for each center. The "Address" column only has the street address. We will create a field collection with two fields, "street" and "zipcode", with the goal of inserting the "Address" value into "street" field.

Install Feeds (current stable:7.x-2.0-beta3) and Field collection (7.x-1.0-beta12) modules:

drush dl feeds
drush en -y feeds feeds_ui

drush en -y field_collection

Here is the content type we will use to import the data:

Content type

The "Address" field collection above has the following fields:

Field collection

If we look at the fields available to us before applying the patch, this is what we will see:

List of fields before patch

Our fields collection fields are not available in the list. Let's apply the patch:

# Get patch
curl -LO
cd sites/all/modules/contrib/field_collection/

# Test patch
patch -p1 < ../../../../../add_feeds_integration-1063434-232.patch --dry-run

# Apply patch
patch -p1 < ../../../../../add_feeds_integration-1063434-232.patch

# Clear cache and registry
drush cc all; drush rr; drush cc all

If we check the field list again, we will see our field collection fields:

List of fields after patch

That's it!

Let's work together to deliver a success story.