I'm working on a migration from a CSV into a Drupal 8 site, creating School nodes that include an entity reference field for a Sport taxonomy. The new taxonomy terms I want to use all exist within Drupal already, but they're nested such that a sport ("Basketball") is listed as a parent term, with child terms ("Boys" and "Girls") below them. Because the child terms' names are the same under multiple sports, I'm attempting to target the mapped destinations by their term IDs instead.
Here's an example of what I've tried – this looks similar to a previous answer and produces no errors, but also no Sports mappings. Other tweaks I've made have resulted in either the original terms ("Basketball Men") being imported as new terms or the importer producing errors because those terms aren't IDs.
source:
plugin: csv
path: sites/default/files/data/schools.csv
delimiter: ','
enclosure: '"'
header_row_count: 1
keys:
- id
column_names:
-
id: 'Unique ID'
-
sports: Sports
process:
field_sports:
-
plugin: explode # Because schools have multiple terms...
delimiter: ',' # ...separated by a comma in the spreadsheet
source: sports
-
plugin: static_map
source: sports
map:
'Basketball Men': 37 # Corresponds with the ID for Basketball > Boys
'Volleyball Men': 74 # Corresponds with the ID for Volleyball > Boys
'Volleyball Women': 75 # Corresponds with the ID for Volleyball > Girls
[...]
-
plugin: entity_lookup
value_key: tid
entity_type: taxonomy_term
bundle_key: vid
bundle: sport # The ID of the taxonomy vocabulary
Is there an obvious adjustment I need to make in order for these terms to import properly?
source: sports
line from theplugin: static_map
section: The static map should use the output from the precedingexplode
to get the values, not the whole string from the CSV