0

I have a site with several different Node Types. With some of them having different types within them created with a Text(list) fields.

For Example:

Node Content Type: Chemicals
Label: Chemical Type Machine Name: field_chemical_type Field type: List (text)
  Allowed Values list:
      fertilizer|Fertilizer
      fungicide|Fungicide
      herbicide|Herbicide
      insecticide|Insecticide
      surfactant|Surfactant
      indicator|Indicator

We would like to convert these to a new ECK Content type with separate bundles for each of the Allowed Values. Of which, we have already created them and the bundle types correspond to the "key" values within the Allowed values list.

Is there a way to migrate the entire content type and have the bundles change according to the value designated in the field_chemical_type list?

I have tried the following and it is not working for me:

    langcode: en
    status: true
    dependencies: {  }
    id: seward7_chemical_nodes
    class: Drupal\node\Plugin\migrate\D7NodeTranslation
    field_plugin_method: null
    cck_plugin_method: null
    migration_tags:
      - 'Drupal 7'
      - Content
    migration_group: sew7
    label: 'Chemical Nodes'
    source:
      plugin: d7_node
      node_type: chemicals
    process:
      id:
        -
          plugin: get
          source: nid
      type:
        -
          plugin: get
          source: field_chemical_type
      langcode:
        -
          plugin: default_value
          source: language
          default_value: und
      title:
        -
          plugin: get
          source: title
      created:
        -
          plugin: get
          source: created
      changed:
        -
          plugin: get
          source: timestamp
      field_name:
        -
          plugin: get
          source: field_chemical_name
    destination:
      plugin: 'entity:chemical'
    migration_dependencies:
      required:
        - seward7users
      optional: []

I have read contradicting info on "default_bundle" in the destination. So I am confused. One post says you have to designate a default_bundle another states you don't if you stipulate it in the "type" within the Process side of things.

If I can designate it in the Process, am I using the wrong plugin?

We have several other Node Content Types that we would like to convert into their own entities with separate bundles. So it would be extremely beneficial not to have to create separate yml files for every bundle within the individual entity types.

I am a site builder with a enough coding experience to get myself in trouble. But I want to learn. Any advice or guidance on where to go to learn would be greatly appreciated!

1

1 Answer 1

0

I had updated my development database with what I had thought, just the tables I needed. In doing so I missed the field_config table in the database. So the field I was trying to reference was not getting seen. Thus causing me a couple days of frustration!

@MikeLutzUS also helped me out by noting that I needed to use field_chemical_type/0/value for the type source. The following worked for me:

    langcode: en
    status: true
    dependencies: {  }
    id: seward7_chemical_nodes
    class: Drupal\node\Plugin\migrate\D7NodeTranslation
    field_plugin_method: null
    cck_plugin_method: null
    migration_tags:
      - 'Drupal 7'
      - Content
    migration_group: sew7
    label: 'Chemical Nodes'
    source:
      plugin: d7_node
      node_type: chemicals
    process:
      id:
        -
          plugin: get
          source: nid
      type:
        -
          plugin: get
          source: field_chemical_type/0/value
      langcode:
        -
          plugin: default_value
          source: language
          default_value: und
      title:
        -
          plugin: get
          source: title
      created:
        -
          plugin: get
          source: created
      changed:
        -
          plugin: get
          source: timestamp
      field_name:
        -
          plugin: get
          source: field_chemical_name
    destination:
      plugin: 'entity:chemical'
    migration_dependencies:
      required:
        - seward7users
      optional: []

Big shout out of Thank You! to @MikeLutzUS You can see our conversation on Here

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.