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.

Use prepareRow to Perform Extra Operations

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:00
    Use prepareRow to Perform Extra Operations.
  • 0:07
    JOE SHINDELAR: If you've ever had to deal with data migrations
  • 0:10
    before I'm sure you're aware that it's a very rare thing where
  • 0:13
    our source data looks exactly the way
  • 0:15
    we need it to in our destination.
  • 0:18
    It's common to need to perform some kind of transformation
  • 0:21
    of that data, maybe you need to convert one unit of measurement
  • 0:25
    to another because your new content type in Drupal
  • 0:28
    expects it to be inches instead of feet,
  • 0:30
    or maybe you need to concatenate strings together

Use Preparerow to Perform Extra Operations

Loading...

In this lesson we're going to finish mapping the fields for the player migration and learn about how to deal with source data that requires some additional massaging before being saved to the destination. We'll learn about the use of field mapping callback functions and the migration's prepareRow method as possible spots to perform additional logic during a migration. Then we'll use these techniques to combine our player first and last name fields together for the node title field, deal with our birth and death date fields by concatenating the three source columns together into a single date string, and finally add some additional information to the notes field during import that will allow us to track imported records in the future.

 

Note: This lesson was recorded using the 7.x-2.6 version of the date module, however the 7.x-2.7 version is now out which contains some changes to the module's integration with the migrate module. The biggest change being that the date_migrate module is no longer required and has been deprecated. You can read more about the changes here: https://drupal.org/node/2034231

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