I have a field collection migration that is taking nodes of type Map List from a D6 site which have two fields, a title, and a node reference to entity of type Venue. There anywhere between 1-10 node reference fields on any given Map List.
The Map List nodes are to be migrated to a field collection on the D7 site called field_city_map_list which lives on the D7 nodes of type City. On the D6 site the Map List nodes were referenced on the old City content type via entity reference fields.
With the query and sourceMigrations set I was able to get the field collections to be attached to the correct City node in the D7 site, however in the case where a Map List has multiple node reference fields, the migration creates a single field collection for each node reference.
So where field_city_map_list should have several lists, with multiple node references like this:
CityNode->
Title: Some Title
City Map Lists:
Some List Title 1:
345
677
987
Some List Title 2:
876
678
908
Some List Title 3:
493
It actually gets imported like this:
CityNode->
Title: Some Title
City Map Lists:
Some List Title 1:
345
Some List Title 1:
677
Some List Title 1:
987
Some List Title 2:
876
Some List Title 2:
678
Some List Title 2:
908
Some List Title 3:
493
I thought ordering the query by the map list nid and then by the delta in the field venue nid list would solve the issue but it didn't change the migration results at all. There are no errors or migration messages that appear.
Here is my class:
class FCMapList extends myFieldCollectionMigration {
public function __construct(array $arguments) {
parent::__construct($arguments);
$this->systemOfRecord = Migration::DESTINATION;
$this->description = t('Field Collection: Map List Nodes');
$dependencies = array(
'VenueProfilePage',
'City',
);
$this->dependencies = $dependencies;
$query = Database::getConnection('default', 'legacy')
->select('content_type_map_list', 'ml')
->fields('ml', array('nid', 'field_link_title_value'));
$query->join('content_field_venues', 'v', 'v.nid=ml.nid');
$query->fields('v', array('nid', 'field_venues_nid'));
$query->join('content_field_lists', 'l', 'l.field_lists_nid=ml.nid');
$query->fields('l', array('nid'));
$query->orderBy('ml.nid');
$query->orderBy('v.delta', 'ASC');
$query->isNotNull('v.field_venues_nid');
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationFieldCollection('field_city_map_list', array('host_entity_type' => 'node'));
$this->addFieldMapping('host_entity_id', 'l_nid')
->sourceMigration('City');
$this->addFieldMapping('field_list_title', 'field_link_title_value');
$this->addFieldMapping('field_venues', 'field_venues_nid')
->sourceMigration('VenueProfilePage');
$source_key = array(
'nid' => array(
'type' => 'int',
'description' => 'List content ID',
'alias' => 'ml'
)
);
$this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationFieldCollection::getKeySchema());
}
}
I had found a similar question that was self-answered however as I said above, ordering by source node nid and field delta did not solve the issue.
I'm on migrate version: 7.x-2.6-rc1+57-dev and field collection version: 7.x-1.0-beta7