Score:0

Converting Node Type to New ECK Content Type

us flag

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!

tawellman avatar
us flag
@MikeLutzUS helped me on Slack [https://drupal.slack.com/archives/C226VLXBP/p1675115618892409]
Score:0
us flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.