Working example for entity_type: paragraph ?

Created on 30 July 2023, 11 months ago
Updated 8 February 2024, 5 months ago

Does anyone have a working example for a paragraph using version migrate_file_to_media 2.0.9?

I have been successful in getting entity_type:node image fields moved over to media fields. I'm using the same module for a paragraph, but it is doing the following:
1. Only migrating some of the data
2. the Media image fields are not attaching to the paragraph within the node.

This paragraph is within a paragraph if that even matters.

This is step 1

# File to Media Migration configuration for Migrate Slides image field to Slides Media migration

id: slides2_media_step1
label: Migrate Slides image field to Slides Media Media
migration_group: media
source:
  plugin: media_entity_generator
  entity_type: paragraph
  bundle: slides
  langcode: und
  field_names:
    - field_slide_image

destination:
  plugin: entity:media

process:
  bundle:
    plugin: default_value
    default_value: image

  # Using the alt tag if available, else the file name.
  name:
    plugin: media_name
    source: file_name

  # This process plugin will skip the whole row if a existing media is found.
  existing_media_file:
    plugin: check_media_duplicate
    source: target_id

  # This process plugin will skip the whole row if a duplicate image is found.
  unique_file_id:
    plugin: check_duplicate
    source: target_id


  # Map the field image
  field_media_image/target_id: target_id
  field_media_image/alt: alt
  field_media_image/title: title

  langcode: langcode
  uid: uid


dependencies:
  module:
    - slides2_media
  enforced:
    module:
      - slides2_media

This is step 2

# This migration links the newly created media entities with entity reference field on the target bundle.

id: slides2_media_step2
label: Migrate Slides image field to Slides Media Mapping
migration_group: media
source:
  plugin: content_entity:paragraph
  bundle: slides
  include_translations: false

destination:
  plugin: entity:paragraph

process:
  nid: nid

  type:
    plugin: default_value
    default_value: slides
    
  field_slide_image_media:
    plugin: file_id_lookup
    source: field_slide_image
    migration: slides2_media_step1
    no_stub: true


migration_dependencies:
  optional:
  - slides2_media_step1

dependencies:
  module:
    - slides2_media
  enforced:
    module:
      - slides2_media
πŸ’¬ Support request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States niner94949

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @niner94949
  • πŸ‡ΊπŸ‡ΈUnited States niner94949
    Migrate Slides image field to Slides Media Mapping 	slides2_media_step2 	Idle 	37352 	0 	37352 	0 		
    Migrate Slides image field to Slides Media Media 	        slides2_media_step1 	Idle 	0 	        0 	       0 	0
    
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    Seems like you forgot to run drush migrate:duplicate-file-detection <migration_name> before migration.
    This is a required action to fill in the mapping table. Without it, your files won't be migrated.

    Close the ticket if this is your point, please.

  • Status changed to Closed: works as designed 9 months ago
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    Closed the ticket after 2 weeks of silence

  • πŸ‡¨πŸ‡¦Canada lindsay.wils

    In case anyone else gets here with the same question, my issue seems to be the same as im guessing for the OP.

    In step2
    nid: nid

    needs to be replaced with
    id: id

    As Paragraph entity uses id and node entity uses nid.

Production build 0.69.0 2024