Score:0

Save multiple taxonomy terms in migration from array of tids

in flag

I'm having some issues with storing multiple taxonomy terms in a field as part of a migration.

I've created a custom plugin get_colors that returns an array of existing tids. A custom process plugin was needed her as the source values don't map cleanly.

pseudofield_colors:
    plugin: get_colors
    source: keywords

I can get a single tid value to work correctly but can't figure out how to iterate through this array and assign multiple values.

field_color:
    plugin: sub_process
      source: '@pseudofield_colors'
      process:
        target_id:
          plugin: entity_lookup
          source: target_id
          entity_type: taxonomy_term
          bundle: my_colors
          bundle_key: vid
          value_key: target_id

I'm lost in two ways:

  1. What format should my return array be in? Should it just be an array of tids ["0" => "123", "1" => "567"] or does it need to have specific keys?
  2. I found a lot of documentation on using sub_process and entity_lookup. Is entity_lookup necessary here? Returning a single tid works so I'd assume I could somehow iterate through my array and just assign multiple values but this is where I'm getting really stuck.

Thanks for the help!

miststudent2011 avatar
fr flag
Does this help ? https://drupal.stackexchange.com/a/304157/
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.