Closed (fixed)
Project:
Migrate
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2009 at 19:47 UTC
Updated:
9 Jun 2009 at 12:47 UTC
Jump to comment: Most recent file
Comments
Comment #1
mikeryanThe migrate module is inherently based on one input row from the view creating one object. To deal with multiple fields per object, you can do the work in the prepare_node hook. For the given study guide, query the course nodes related to it and fill them into the $node object. Something like:
Does this help?
Comment #2
attheshow commentedAwesome. I was struggling. I'll give this a shot and see if I can successfully implement it. Thanks Mike!
Comment #3
attheshow commentedSo this is close to working for me, but for some reason, I can't seem to successfully fill in the node field with multiple values. I've attached some screenshots and here's the code I'm running for this node->type inside my prepare_node hook:
My query is definitely working. The single "material" node that I'm importing has two courses associated with it, and those two values are being filled in the way that I mean for them to (you can see this in the "dsm_node_after_modification.png" screenshot). But when I go look at the node, the field doesn't appear to have the nid values in it. Any ideas of what might be wrong with this setup?
Comment #4
mikeryanI was a little lazy - try $i = 0 before the loop...
Comment #5
attheshow commentedOk, I tried making that adjustment. Now the "field_course_nid" array gets keys of 0 and 1 (see screenshot), but the result is the same. The actual field isn't being populated with the two values when the migration happens.
Comment #6
attheshow commentedI just looked through content.inc and saw a message that says:
Is that possibly the issue that I'm running into here?
Comment #7
attheshow commentedOk, I think I've got it working for the moment. Just in case anyone else wants to do this, here's the code I ended up using to fill in a multiple value field:
Also, I highly recommend using Views to create the query that you need and then copy/paste it into your hook here.
Comment #9
robertdouglass commentedHere's the code I used to do multiple value fields, in case it helps someone: