Skip to content

Instantly share code, notes, and snippets.

@jasloe
Last active August 5, 2021 19:19
Show Gist options
  • Save jasloe/5ef5fa04817282445fecc0b690a37743 to your computer and use it in GitHub Desktop.
Save jasloe/5ef5fa04817282445fecc0b690a37743 to your computer and use it in GitHub Desktop.
node-paragraph-migration.md

data source

{
    "field_article_page_section": [
        {
            "target_id": 814,
            "target_revision_id": 814,
            "target_type": "paragraph",
            "target_uuid": "e1a8229f-0c7e-43dc-8942-d8e8915478d0"
        },
        {
            "target_id": 815,
            "target_revision_id": 815,
            "target_type": "paragraph",
            "target_uuid": "96ed2e09-f856-40ee-8c5a-63fc56b2ef9b"
        },
        {
            "target_id": 1130,
            "target_revision_id": 1130,
            "target_type": "paragraph",
            "target_uuid": "7ea62436-7abc-4d5e-b42d-a6f866fcd839"
        },
        {
            "target_id": 816,
            "target_revision_id": 816,
            "target_type": "paragraph",
            "target_uuid": "04e7e893-f3ba-40d2-b8f0-8d91d92abfb1"
        },
        {
            "target_id": 1131,
            "target_revision_id": 1131,
            "target_type": "paragraph",
            "target_uuid": "209a4df5-7eb0-4426-ab3f-184a567b9d9e"
        },
        {
            "target_id": 817,
            "target_revision_id": 817,
            "target_type": "paragraph",
            "target_uuid": "cc7bb55f-64d6-4ba5-969d-87121b4e9dbb"
        },
        {
            "target_id": 1132,
            "target_revision_id": 1132,
            "target_type": "paragraph",
            "target_uuid": "b52762ce-15a6-45ae-952c-180be9f9a0f4"
        },
        {
            "target_id": 818,
            "target_revision_id": 818,
            "target_type": "paragraph",
            "target_uuid": "f9721422-67e3-4269-bd48-6c2ea7525130"
        },
        {
            "target_id": 819,
            "target_revision_id": 819,
            "target_type": "paragraph",
            "target_uuid": "350e2118-495a-4123-b5a0-6e9ac69cc75c"
        }
    ],
    "nid": [
        {
            "value": 587
        }
    ],
    "title": [
        {
            "value": "Bucking the Tradition"
        }
    ],
}

extract

source:
  item_selector: 0
  fields:
    -
      name: src_nid
      selector: /nid/0/value
    -
      name: src_title
      selector: /title/0/value
    -
      name: src_field_article_page_section
      selector: /field_article_page_section
  ids:
    src_nid:
      type: integer

transform

process:
  type:
    plugin: default_value
    default_value: article
  title: src_title
  pseudo_fetch_page_section:
    plugin: sub_process
    source: src_field_article_page_section
    process:
      ids:
        plugin: migration_lookup
        migration: sa_article_page_section
        source: target_id
            
  field_page_section: ??? // this is the part I'm having trouble with

load

destination:
  plugin: entity:node

destination

^ "---------------------------------------------------------------------"
^ "|                           $Destination                            |"
^ "---------------------------------------------------------------------"
^ array:9 [
  "title" => "Bucking the Tradition"
  "pseudo_fetch_page_section" => array:9 [
    0 => array:1 [
      "ids" => array:2 [
        0 => "200"
        1 => "200"
      ]
    ]
    1 => array:1 [
      "ids" => array:2 [
        0 => "610"
        1 => "610"
      ]
    ]
    2 => array:1 [
      "ids" => array:2 [
        0 => "611"
        1 => "611"
      ]
    ]
    3 => array:1 [
      "ids" => array:2 [
        0 => "612"
        1 => "612"
      ]
    ]
    4 => array:1 [
      "ids" => array:2 [
        0 => "613"
        1 => "613"
      ]
    ]
    5 => array:1 [
      "ids" => array:2 [
        0 => "614"
        1 => "614"
      ]
    ]
    6 => array:1 [
      "ids" => array:2 [
        0 => "615"
        1 => "615"
      ]
    ]
    7 => array:1 [
      "ids" => array:2 [
        0 => "616"
        1 => "616"
      ]
    ]
    8 => array:1 [
      "ids" => array:2 [
        0 => "617"
        1 => "617"
      ]
    ]
  ]
]
^ "---------------------------------------------------------------------"
^ "|                       $DestinationIdValues                        |"
^ "---------------------------------------------------------------------"
^ array:1 [
  0 => "29048"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment