I'm currently working on a migration module where I use different XML sources (supplied by external provider) to import a movie theater program. I get separate files for movies, theaters and showtimes like this (simplified):
<Movies>
<Movie>
<movieid>14652</movieid>
<title>Movie Title</title>
</Movie>
</Movies>
<Theaters>
<Theater>
<theaterid>75102</theaterid>
<description>Blabla</description>
</Theater>
</Theaters>
<Showtimes>
<Showtime>
<showtimeid>147001169</showtimeid>
<movieid>14652</movieid>
<theaterid>75102</theaterid>
<date>2013-12-02 20:15</date>
</Showtime>
</Showtimes>
I'm already able to import all needed data and create nodes for each type. EXCEPT the relationships between them. I'm not sure which kind of field I should use for this. Currently I'm using entity references, but I have no clue how to set them up properly and if they are the best choice for this kind of application. The plan is to display the showtime information depending on movies or theaters (e.g. show all movies currently played in selected theater or show all theaters for a given movie. Another related question. Should I overwrite the node ids (nid) with the given ids from the xml (is this save?) or shall I create different fields for them?
Thanks in advance for any help! If any more information is needed I will answer immediately ;)
Best regards, Satara
Solution
I just had to use the sourceMigration() function with the migration key defined in the 'migrations' array in the override of migrate_api() file as parameter). Now the ids get mapped properly in the entity_refernce fields:
$this->addFieldMapping('field_showtime_movie', 'movieid')->xpath('movieid')->sourceMigration('Movie');
$this->addFieldMapping('field_showtime_theater', 'theaterid')->xpath('theaterid')->sourceMigration('Theater');