Main menu

Drupal Migration Tip: Do not use EntityFieldQuery in prepareRow()

There are times when you might need to retrieve data about another entity when processing a migration. You might need to do this in the prepareRow method of your Migration class. However, Running an EntityFieldQuery in the prepareRow method will cause your migration to fail. Why? well, I'm still investigating exactly why, but I have narrowed down that it marks you migration as running and then tries to go back in and process it again. In this case, it will throw an error saying that you already have a running process and stop running the migration.
The solution is to move your EntityFieldQuery to a separate method that will return the value you need from the query. Call the method from the prepareRow method with whatever parameters are needed and then use the returned value however you need to in prepare row.
This is just better programming anyway, as you are practicing encapsulation.

© 2012 Carson Black. Drupal theme by Kiwi Themes.