1

I have a JSON that can hold single or multi values arrays and I can't make subprocess + migration_lookup behave consistently. It correctly imports the nodes in all cases, but it adds the reference to the imported nodes (entity reference field) only when I have more than 1 item in my array.

my JSON can looks like this:

"behaviour": [
          {
            "name": "behaviour name",
            "description": "behaviour description"
          }
        ]

or like this:

"behaviour": [
          {
            "name": "behaviour name",
            "description": "behaviour description"
          },
          {
            "name": "another behaviour name",
            "description": "another behaviour description"
          }
        ]

the process part of my migration config:

  field_behaviour:
    plugin: sub_process
    source: behaviour_array
    process:
      target_id:
        plugin: migration_lookup
        migration: import_behaviours_json
        source: name

2 Answers 2

0

This is just guessing, but you could try forcing the multiple flag on the source field using the multiple_value plugin from Migrate Plus:

field_behaviour:
  -  
    plugin: multiple_values
    source: behaviour_array
  -  
    plugin: sub_process
    process:
      target_id:
        plugin: migration_lookup
        migration: import_behaviours_json
        source: name
1
  • Thanks, but it doesn't seem to fix the issue. BTW, sub process already seems to handle values as multiple.
    – Stefan
    Jul 8, 2020 at 19:22
0

It urned out the issue was related with migrate_source_jsonpath (the modules used to grab data from JSON).

migrate_source_jsonpath was the one returning single items as strings instead of array.

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.