Skip to content

Instantly share code, notes, and snippets.

@eojthebrave
Created July 14, 2021 16:42
Show Gist options
  • Save eojthebrave/5bd48c3cbf456dec7c673ea28e6172a9 to your computer and use it in GitHub Desktop.
Save eojthebrave/5bd48c3cbf456dec7c673ea28e6172a9 to your computer and use it in GitHub Desktop.
Merge two diffferent Drupal 7 vocabularies into a single Drupal 8/9 vocabulary and dedupe terms
id: dme_d7_taxonomy_term_tags
migration_group: dmemigration
label: 'Taxonomy terms (Tags & Blog tags)'
source:
plugin: d7_taxonomy_term
# We're merging the D7 blog_tags, and tags taxonomies into one.
bundle:
- tags
- blog_tags
process:
tid:
-
# First check to see if there's already a term with the
# same name. If so, use it's TID. Effectively deduping
# terms. For duplicate terms this will create two records
# in the map table both of which point to the same destid1
# so using migration_lookup will work regardless of which
# of the two terms the migrated content used.
plugin: entity_lookup
source: name
value_key: name
bundle_key: vid
bundle: tags
entity_type: taxonomy_term
ignore_case: true
-
# If not, use next available TID.
plugin: default_value
default_value: null
vid:
-
# Force all terms to use same vocab, regardless of
# source vocab.
plugin: default_value
default_value: 'tags'
name:
-
plugin: get
source: name
description/value:
-
plugin: get
source: description
description/format:
-
plugin: get
source: format
parent:
-
plugin: default_value
default_value: 0
changed:
-
plugin: get
source: timestamp
langcode:
-
plugin: get
source: language
destination:
plugin: 'entity:taxonomy_term'
default_bundle: tags
migration_dependencies:
required: []
optional: []
# Snippet from blog post migration showing how to move data from D7
# blog_tags field to new D8 tags field using a migration_lookup.
process:
taxonomy_tags:
-
plugin: sub_process
source: taxonomy_blog_tags
process:
target_id:
-
plugin: migration_lookup
migration: dme_d7_taxonomy_term_tags
source: tid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment