How to set a specific vocabulary in a taxonomy reference field during migration?

by Paul   Last Updated June 27, 2018 10:07 AM - source

I am doing a D7 > D8 migration (where the D7 site in question itself was migrated from D6 some years back) and most stuff just works fine. But I am stuck on the field (instance) settings for taxonomy reference fields.

When migrating the field instances, I am using a slightly changed version from the one provided by core (that's how I did it with most other stuff, too):

langcode: en
status: true
dependencies: {  }
id: my_fields
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processField
cck_plugin_method: null
  - 'Drupal 7'
  - Configuration
migration_group: my
label: 'Field configuration'
  plugin: d7_field
    status: true
    langcode: und
  entity_type: entity_type
  status: constants/status
  langcode: constants/langcode
    plugin: static_map
    source: field_name
      taxonomy_vocabulary_1: field_issues
      taxonomy_vocabulary_2: field_tags
    bypass: TRUE
    plugin: process_field
    source: type
    method: getFieldType
  cardinality: cardinality
    plugin: d7_field_settings
  plugin: 'entity:field_storage_config'
migration_dependencies: null

When I run this via drush mim my_fields all field instances on all content types are created (wonderful!), the only thing missing is the restriction in taxonomy term reference fields regarding a specific vocabulary.

When I create such a field manually and export the configuration, there is a section in the yaml file describing that restriction:

  handler: 'default:taxonomy_term'
      issues: issues
      field: name
      direction: asc
    auto_create: false
    auto_create_bundle: ''

I guess this needs to be in the process section of the migration configuration, but how do I set it correctly? If I read that right, the vocabulary name (issues) is both field name and value, which would probably pose a problem for multiple vocabularies. Also, how would I set this for taxonomy reference fields only?

Added note: In Drupal 7, the restriction was set within the field global settings (allowed_values[vocabulary], could be found in the DB table field_config) and not with the field instance.

In Drupal 8, it seems to be a field_instance setting as the same field can be restricted to different vocabularies in different content types. May that be the reason, why this setting is not migrated?

By the way: I did try a simple migration first by using the Migrate Drupal module and while it got most configuration right by just using defaults, here also the restrictions on taxonomy reference fields was missing.

Related Questions

How to edit vocabulary machine name?

Updated November 29, 2017 21:07 PM

migrate taxonomy term csv

Updated May 14, 2018 17:07 PM

Auto-create terms during node migration

Updated July 27, 2018 15:07 PM