I'm using migrate module, but I don't understand how to get "uid" from my "MigrateMhtAuthor" class (it is sourceMigration setting). I have this code in my main class:
class MigrateMhtAdsMigration extends DynamicMigration {
public function __construct() {
parent::__construct();
[...]
$uid_mapping = $this->addFieldMapping("uid","utente")->sourceMigration('MigrateMhtAuthor');
[...]
}
}I know that MigrateMhtAuthor works because I have imported my user with this migrate class.
I have create some "debug" point in the MigrateMhtAuthor class and this is the output when I import/migrate a node:
MigrateMhtAuthorMigration __construct
MhtAuthorDestination __construct
MigrateMhtAuthorMigration fine[MhtAuthorDestination is a class that make the real insert. It search if the user exist (based on email check) to prevent the double email error]
So, I can see that the MigrateMhtAuthor is call, but when I go to see the uid of the node that I have just imported/migrate I see "1" (uid = 1).
Where is my error ? If you want to see my classes can I insert a link to pastebin?
Comments
Comment #1
ziobudda commentedI have found a way, but I don't understand why in this way works.
The new code is:
So, I don't understand what "sourceMigration()" mean if I need to use "handleSourceMigration" in prepareRow() function.
Comment #2
mikeryanSo, are you saying that this does not work in your constructor?
Based on what you put in prepareRow(), it appears that "id" is where the source user ID is stored in the row, so that's the field to map to "uid" (in your original sample you were mapping "utente").
Comment #3
mikeryan