2

Am trying to migrate a taxonomy-reference field attached to a field_collection entity-type (Drupal 7) into an entity-reference field attached to a paragraphs entity-type (Drupal 8.6).

Although it seems one of the basic tasks to do while migration but I couldn't find a clear reference of how to do it.

id: d7_field_collection_field_name
label: My Field name
migration_tags:
  - Drupal 7
migration_group: migrate_drupal_7

source:
  plugin: d7_custom_source_plugin
process:
  field_title:
    plugin: get
    source: field_title
  field_job_category:
    plugin: get
    source: field_job_category
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: my_paragraphs_bundle
migration_dependencies:
  required:
    - upgrade_d7_field
    - upgrade_d7_node_type
    - upgrade_d7_field_collection_type
    - upgrade_d7_field_instance

The migration process is explained here: https://www.mtech-llc.com/blog/ada-hernandez/migration-field-collection-d7-paragraphs-node-d8

So, field_job_category is not working. I tried so many ways in process plugins without luck. For example I used:

  field_job_category:
    plugin: migration_lookup
    migration: upgrade_d7_taxonomy_term_job_categories
    source: term_id

Then tried to use sources since am using Drupal 8.6

  field_job_category:
    plugin: migration_lookup
    migration: upgrade_d7_taxonomy_term_job_categories
    sources:
      upgrade_d7_taxonomy_term_job_categories:
        - term_id

I believe its a configuration mistake under field_job_category, but i couldn't figure it out yet.

Your help is much appreciated!

1 Answers1

0

This has been resolved by doing two things.

First, use sub_process process plugin for my field.

field_job_category:
  -
    plugin: sub_process
    source: field_job_category
    process:
      target_id: tid

Finally, implement hook_migrate_prepare_row() to provide data with right structure to be consumed by the above sub_process

$row->setSourceProperty($field_name, $new_value);

And $new_value should be

Array
(
  [0] => Array
    (
        [tid] => Term ID
    )
 )

Hope this helps! Cheers.