Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Using sourceMigrations to Add Related Data

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:02
    Using sourceMigrations to Add Related Data
  • 0:04
    with Joe Shindelar
  • 0:07
    JOE SHINDELAR: In this lesson we're going to take a look at populating
  • 0:10
    the entity reference field that tracks the relationship
  • 0:13
    between a team node and a player node.
  • 0:16
    In our source data we have this information.
  • 0:19
    We know the idea of a player and the idea of a team
  • 0:22
    as tracked in the source data.
  • 0:24
    So we can write a migration that will allow us to import all
  • 0:26
    of the teams, but then they'll have new node IDs, so how

Using Sourcemigrations to Add Related Data

Loading...

In this lesson we're going to take a look at creating relationships between two Drupal nodes during a migration. In our case we've got player and team nodes, and each player node has an entity reference to a team node which we need to populate during our migration. In order for this to work we need to ensure that the team node has already been created so that we know the unique node.nid to use in the entity reference field for the player.

To accomplish this we're going to write a migration for team data and ensure that it is run prior to our player migration being run. Then we're going to make use of the mapping between source and destination rows that the Migrate module is tracking for teams so that during a player migration we can lookup the corresponding team node's nid and make use of it.

Downloads: 
Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.