I have a node migration using the d7_node source plugin.
I'm trying to migrate the values of a multi-value taxonomy term reference field into a multi-value taxonomy reference field in D9. There is a separate migration to import the taxonomy terms that works great.
In my node migration, I have something like:
field_my_tax_field:
plugin: migration_lookup
migration: my_taxonomy_migration_id
source: field_my_d7_tax_field
However, this throws an exception and the migration fails. When I throw a breakpoint in Drupal\migrate\Plugin\migrate\process\MigrationLookup::transform() (where the exception is thrown), I can see that the value being passed is an array, but the lookup plugin wants a scalar value. The array passed is something like:
['target_id' => 123]
With this info, I can make this work by updating my migration config with something like:
field_my_tax_field:
- plugin: callback
callable: reset
source: field_my_d7_tax_field
- plugin: migration_lookup
migration: my_taxonomy_migration_id
Using reset()
like this feels loose. And it seems weird that this extra step is necessary, this seems like use-case #1 for the migration_lookup function.
What am I missing? How can I do this in a better way?