Migration into multi-value field collection I am attempting to use the patch in comment #222 of this issue (https://drupal.org/node/1175082#comment-7625869) to migrate data into a multi-value field collection. 

I create an array of the objects in prepareRow() but when the migration completes and I review the nodes, only the first item in the array has populated the field collection and no subsequent items have been added. Am I missing something important?

&lt;?php
class IngredientsMigration extends BasicMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this-&gt;description = t('Migrate recipe ingredients from the source database into field collections.');
    $this-&gt;dependencies = array('Recipe');

    $query = Database::getConnection('default', 'legacy')
      -&gt;select('recipes', 'r')
      -&gt;fields('r', array('id', 'ingredients'))
        -&gt;condition('r.id', array(2), 'IN');

    $this-&gt;source = new MigrateSourceSQL($query);
    $this-&gt;destination = new MigrateDestinationFieldCollection(
      'field_collection_ingredients',
      array('host_entity_type' =&gt; 'node')
    );

    $this-&gt;map = new MigrateSQLMap($this-&gt;machineName,
      array(
        'id' =&gt; array('type' =&gt; 'int',
          'length' =&gt; 11,
          'not null' =&gt; TRUE,
          'description' =&gt; 'Recipe ID',
          'alias' =&gt; 'r',
          ),
      ),
      MigrateDestinationFieldCollection::getKeySchema()
    );

    $this-&gt;addFieldMapping('host_entity_id', 'id')
      -&gt;sourceMigration('Recipe')
      -&gt;issueNumber(16);
    $this-&gt;addFieldMapping('field_ingredient_text', 'ingredients')
      -&gt;description(t('See prepareRow method'))
      -&gt;issueNumber(16);

    $this-&gt;addUnmigratedDestinations(array(
      'path',
      )
    );
  }

  public function prepareRow($row) {
    // Always include this fragment at the beginning of every prepareRow()
    // implementation, so parent classes can ignore rows.
    if (parent::prepareRow($row) === FALSE) {
      return FALSE;
    }

    $ingredients_array = preg_split('/$\R?^/m', $row-&gt;ingredients);
    $row-&gt;ingredients = array();
    foreach ($ingredients_array as $ingredient) {
      $row-&gt;ingredients[] = $ingredient;
    }
    return TRUE;
  }
}
I ended up writing a drush command to run before the migration that would take the 'ingredients' field from the source db and create a new table with the ingredients each parsed into their own row and a delta column to keep them in order. I then configured the ingredients migration to point to this table instead of the recipe table.

My DB connection for this migration ended up looking like the following:

$query = Database::getConnection('default', 'legacy')
  -&gt;select('_recipe_ingredients', 'i')
    -&gt;fields('i', array('id', 'recipe_id', 'ingredient'))
    -&gt;orderBy('i.recipe_id')
    -&gt;orderBy('i.delta');