It seems that this should be completely straightforward (http://drupal.org/node/1536914) , but I can't get it to work.

I have two node migrations at the moment: clubs and athletes. Athletes is dependent on clubs, and clubs has already run successfully. The Athlete node contains an entity reference field, field_club, that points to Club nodes. In the migration class that handles Athletes, I have:

$this->addFieldMapping('field_club', 'club')
->sourceMigration('ImdClub');

I've verified that the value of club is correct. If I map club to another field using the same source migration parameter, I see the expected NID appear in that field. However, I can't get this value to migrate into the entity reference field, field_club. After the athlete migration, field_club is empty, i.e. no value for target_id at:

$node->field_club['und'][0]['target_id']

Do I need to do more than this to get entity reference to recognize the mapped value as the target_id?

Working with Migrate 7.x-2.5 and Entity Reference 7.x-1.0

Thanks in advance for any help or pointers for troubleshooting!

Dave

CommentFileSizeAuthor
#2 entityreference_migrate-1845986-2.patch414 bytesmikeryan

Comments

mikeryan’s picture

My bad, patch coming...

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new414 bytes

Try this.

dave bruns’s picture

Status: Needs review » Fixed

That's it. Awesome.

Thanks for the great support!

mikeryan’s picture

Status: Fixed » Needs review

Not so fast with the closure;) - until it's committed to the module other migrators will face the same problem.

I did these patches for all the field-handling modules I could find, to my relief this looks like the only one I screwed up...

mikeryan’s picture

Category: support » bug
dave bruns’s picture

Right. That makes sense.

I realized that I had found a bug, but I was thinking only about my own situation :-)

marcoka’s picture

ok the patch seems right according to the latest migrate changes here: http://drupal.org/node/1824884
see heading "Destination and field handler classes"

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

benjifisher’s picture

Thanks to all: dave bruns for reporting the bug, mikeryan for fixing it, and Amitaibu for committing it. You all make my job easier!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.