0

I'm having issues now trying to migrate a local based json file. The goal is to create a node based on the data comming from the json file. For that I allready created a content type 'Produkt' with machine name 'produkt'. The content has some fields and one of them is a paragraph (entity reference revision), that has is own field. So i need two migration files, one for migrating records from json file as paragraphs into d8 and the other to migrate to the entity:node.

I have 31 Products.

Here is the structur of my json file:


{
    "data": [
        {
            "uuid": {
                "value": "0142f404-0289-42ec-b26b-ab1ce7798fd5",
                "parent": false
            },
            "name": {
                "value": "P1",
                "parent": false
            },
            "supplierName": {
                "value": "U1",
                "parent": false
            },
            "description": {
                "value": "",
                "parent": true
            },
            "mandatoryInformation": {
                "value": "",
                "parent": true
            },
            "technicalInformation": {
                "value": "",
                "parent": false
            },
            "packageInformation": {
                "value": "",
                "parent": false
            },
            "productSpecifications": {
                "data": [
                    {
                        "name": {
                            "value": "p11",
                            "parent": false
                        },
                        "npp": {
                            "value": "1385002",
                            "parent": true
                        },
                        "amount": {
                            "value": "28",
                            "parent": false
                        },
                        "packagingUnit": {
                            "value": "lo",
                            "parent": false
                        },
                        "packagingSize": {
                            "value": "NN",
                            "parent": false
                        },
                        "atcCode": {
                            "value": "0o",
                            "parent": false
                        },
                        "labelling": {
                            "value": "",
                            "parent": false
                        },
                        "dosageForm": {
                            "value": "Tabletten",
                            "parent": false
                        },
                        "activeSubstances": {
                            "value": "Pioglitazon hydrochlorid",
                            "parent": false
                        },
                        "activeSubstancesWithAmounts": {
                            "value": "plo",
                            "parent": false
                        },
                        "indications": {
                            "data": [
                                {
                                    "code": {
                                        "value": "00.00",
                                        "parent": true
                                    },
                                    "codeDescription": {
                                        "value": "leo",
                                        "parent": true
                                    }
                                }
                            ]
                        },

So here is the yml file configuration for my paragrpahs migration:


id: produkte_paragraph
label: Migrate Paragraph content from json file into Drupal 8
migration_group: produkt

source:
  plugin: migrate_source_url
  track_changes: true
  data_fetcher_plugin: file
  data_parser_plugin: json
  urls: data/json/data.json

  item_selector: /data
  fields:

    -
      name: name
      label: 'Produkt name'
      selector: productSpecifications/data/name/value

    - name: npp
      label: 'Produkt Npp'
      selector: productSpecifications/data/npp/value

  ids:
    npp:
      type: string

process:

  field_produkt_name: name
  field_produkt_npp: npp



  uid:
    plugin: default_value
    default_value: 1

  type:
    plugin: default_value
    default_value: productspecifications(the paragrap_type)




destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: productspecifications


migration_dependencies:
  required: {}
  optional: {}

When running: drush mim produkte_paragraph, I get:


Processed 1 item (1 created, 0 updated, 0 failed, 0 ignored) - done with 'produkte_paragraph'

The migration olny proceeds 1 from 31 products. and there is no reference to one of the nodes created

here is the yml configuration file for my entity:node


id: migrate_json_file
label: Migrate content from json file
migration_group: produkt

source:
  plugin: migrate_source_url
  track_changes: true
  data_fetcher_plugin: file
  data_parser_plugin: json
  urls: data/json/data.json


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

  - name: name
    label: 'Produkt Name'
    selector: name/value

  - name: supplierName
    label: 'Anbietername'
    selector: supplierName/value

  - name: description
    label: 'Beschreibung'
    selector: description/value

  - name: mandatoryInformation
    label: 'Pflichtangaben'
    selector: mandatoryInformation/value

  - name: technicalInformation
    label: 'Fachinformationen'
    selector: technicalInformation/value

  - name: packageInformation
    label: 'Gebrauchsinformationen'
    selector: packageInformation/value



  ids:
    uuid:
      type: string

destination:
  plugin: entity:node

process:

  langcode:
    plugin: default_value
    default_value: "und"

  type:
    plugin: default_value
    default_value: produkt

  title: name
  field_uuid: uuid
  field_suppliername: supplierName
  field_description:  description
  field_mandatory_info: mandatoryInformation
  field_technical_info: technicalInformation
  field_package_info: packageInformation
  field_productspecifications:
    plugin: iterator
    source: productSpecifications/data
    process:
      temporary_ids:
        plugin: migration_lookup
        migration: takeda_produkte_paragraph
        no_stub: true
        source: npp
      target_id:
        plugin: extract
        source: '@temporary_ids'
        index:
          - 0
      target_revision_id:
        plugin: extract
        source: '@temporary_ids'
        index:
          - 1



  uid:
    plugin: default_value
    default_value: 1

migration_dependencies:
  required: {}
  optional:
    - produkte_paragraph

dependencies:
  enforced:
    module:
      - migration_json_file

The migration of entity:node works fine, but when running the migration of paragraphs, I can only process one item (1), but there is no reference between the migrated paragraph and one of the entity:node.

I have try anything but I can not get it work

!!!!!!!!!! Help really needed !!!!!!!!!!!!!!

Your Answer

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

Browse other questions tagged or ask your own question.