2

I am using migrate source CSV and trying to extract a string which contains multiple key/value pairs of links in format:

"Google.com|https://google.com,Yahoo.com|https://yahoo.com"

I need to save the values into a multiple link field.

The logic I need to run is:

- Explode the string on comma ,
- Iterate each item
  - Explode string on pipe |
    - Extract index 0
      - Store to field_link/title
    - Extract index 1
      - Store to field_link/uri

I have it working using a custom process plugin but would like to try and achieve this if possible through chaining of the core process plugins in the migration config yml file.

Thanks

1 Answer 1

4

Here is my solution to solve a similar problem:

temp_data:
  -
    source: data
    plugin: explode
    delimiter: ','
  -
    plugin: explode
    delimiter: '|'
destination_field:
  plugin: sub_process
  source: '@temp_data'
  process:
    field_attr_1: '0'
    field_attr_2: '1'
    field_attr_3: '2'

Hope it helps.

Regards, M.

1
  • This really helped me. Thank you!
    – Doomd
    Commented Aug 5, 2020 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.