Hi,
I have a migration on which I want to combine a callback with a sourceMigration:
$this->addFieldMapping('field_my_field', 'ID')
->callbacks(array($this, 'convertOldIDToMigrationID'))
->separator(',')
->sourceMigration(array('another_migration'));
The function convertOldIDToMigrationID returns a comma separated string with migration ID's from another_migration. If I run
$this->addFieldMapping('field_my_field', 'ID')
->callbacks(array($this, 'convertOldIDToMigrationID'))
->separator(',');
then I see some dpm's which are located in the callback. However if I add the sourceMigration as well, these dpm's doesn't show up anymore, so it looks like the callback is not executed anymore.
What am I doing wrong? Is it possible to combine a callbacks with a sourceMigration at all?
Comments
Comment #1
mikeryanThe order these options are executed in applyMappings() is:
So, what's happening is:
In this instance, since you need to call convertOldIDToMigrationID before separator() and sourceMigration(), you should be calling it in prepareRow() rather than via a callback.
Comment #2
ToRum commentedThanks! FYI, I got it working by using
prepareRow($row):Comment #3
joseph.olstadMikeryan suggestion was good for me.
My use case: events (evènements) , two fields, one source.
the field_evenement_themes will hold the first categorie
the field_evenement_secondaire will hold all the rest of the categories (if there are any)
Here's my code snippet.
seems to work well so far.