Background:
I am creating new articles in Drupal 9.5 from a source database using the Migrate API. The articles optionally have references to one or more taxonomy terms. I have already created the taxonomy terms in Drupal manually, they look good. I then use the entity_lookup process plugin to lookup the taxonomy IDs as part of the article migration. But when the taxonomy terms repeat, they don't seem to be getting picked up right.
Problem:
Minimal migration YAML snippet is below.
Somehow only 'term1' in data row '1' keeps getting set in Drupal correctly when the migration is run. Nothing is set for row '2' (which is correct behavior) and nothing for row '3' either (incorrect behavior). I narrowed down the issue to repeating taxonomy terms, but cannot figure out what is going wrong. I have used the same construct with the explode plugin along with entity_generate and they worked well (but I don't want to go the route of entity_generate).
These links (this and this) referred to in past threads don't help much as the examples and explanations appear incomplete. If anyone can throw better light on this and where I am going wrong in the YAML, would be grateful. Thank you!
source:
plugin: embedded_data
data_rows:
-
unique_id: 1
title: 'xxx'
description: "xxxxx"
taxoterms: 'term1'
-
unique_id: 2
title: 'xxxx'
description: "xxxxxxx"
taxoterms: ''
-
unique_id: 3
title: 'xxxx'
description: "xxxxxxxxxxxx"
taxoterms: 'term2,term3'
ids:
unique_id:
type: integer
process:
title: title
body/value: description
body/format:
plugin: default_value
default_value: restricted_html
taxoterms:
-
plugin: skip_on_empty
source: taxoterms
method: process
message: 'Article does not contain taxomony terms'
-
plugin: explode
delimiter: ','
strict: FALSE
source: taxoterms
-
plugin: callback
callable: trim
-
plugin: entity_lookup
entity_type: taxonomy_term
value_key: name
bundle_key: vid
bundle: my_taxo_vocab
destination:
plugin: 'entity:node'
default_bundle: my_article