0

Given following jsons file


{
  "data": {
    "uuid": {
      "value": "ed64784-cjjhd6",
      "patient": false
    },
    "name": {
      "value": "Name",
      "patient": false
    },

how to select the uuid value and set it as ids in the migratin definition yml file?

here is my migration yml file: I really don't know how to select the value of the uuid as ids


id: migrate_json_file
label: Migrate content from local json file
source:
  plugin: source_url
  data_fetcher_plugin: file
  data_parser_plugin: json
  urls: data/data.json

  ids:
    value:
      selector: uuid/value
      type: string
  item_selector: /data
  fields:
  - name: uuid
    label: 'uuid'
    selector: uuid

  - name: title
    label: 'title'
    selector: name


destination:
  plugin: entity:node

  process:
    type:
      plugin: default_value
      bundle: produkt

    title: name
    field_uuid: uuid

  sticky:
    plugin: default_value
    default_value: 0
    uid:
      plugin: default_value
      default_value: 0

    migration_dependencies:
      required: {}
      optional: {}

    dependencies:
      enforced:
        module:
        - migration_json_file


Thank you in advance

Sincerely

Hermann

  • It looks like you may be missing the process section in your migration yml. Should include top level source, process and destination – David Thomas Jan 3 at 23:17
  • Hey David, thank you for your reply, yes you wa right! Thank you very much. – Hermann Jan 4 at 10:58
  • Hi @Hermann you're welcome. I've added the comment as an answer, so that this issue can be resolved. All the best with the project. – David Thomas Jan 7 at 1:21
0

The migration template should include top level source, process and destination sections

It appears in this case you are missing the process section for the field value assignment there.

More info: https://www.drupal.org/docs/8/api/migrate-api/migrate-api-overview#etl

  • Hey David, your answer helped me to run the migration, although this was not the answer of my question your advice helped me avoiding getting more issues. – Hermann Jan 10 at 13:50
0

This worked for me:

The solution for the question: based on the json structure I provided, I could fetch the ids using the following pattern:


id: migrate_json_file
label: Migrate content from local json file
source:
  plugin: source_url
  data_fetcher_plugin: file
  data_parser_plugin: json
  urls: data/data.json

  ids:
    **uuid**
      type: string

  item_selector: /data
  fields:
  - name: uuid
    label: 'uuid'
    **selector: uuid/value**

  - name: title
    label: 'title'
    **selector: name/value**


destination:
  plugin: entity:node

  process:
    type:
      plugin: default_value
      bundle: produkt

    title: name
    field_uuid: uuid

  sticky:
    plugin: default_value
    default_value: 0
    uid:
      plugin: default_value
      default_value: 0

    migration_dependencies:
      required: {}
      optional: {}

    dependencies:
      enforced:
        module:
        - migration_json_file


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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