Score:0

Add created node to parent menu

cn flag

I have a migration that creates nodes from a CSV file. This isn't an export from another Drupal site. It works as expected until I try to add the migrated nodes to a specified menu item.

In the following migration file, publications_create_nodes successfully runs. I can create the menu items for each node with the following.

process:
  menu_name:
    plugin: default_value
    default_value: 'main'
  nid:
    plugin: migration_lookup
    migration:
      - publications_create_nodes
    source_ids:
      publications_create_nodes:
        - id
  'link/uri':
    plugin: concat
    source:
      - constants/path
      - '@nid'
  title: title
  parent:
    plugin: menu_link_parent
    source:
      - 462
      - 'main'
      - '/publications'
  external:
    plugin: default_value
    default_value: 0
  expanded:
    plugin: default_value
    default_value: 0
  enabled:
    plugin: default_value
    default_value: 1
  langcode:
    plugin: default_value
    default_value: 'en'

All these nodes are added to the top level of the main menu.

  parent:
    plugin: menu_link_parent
    source:
      - 462
      - 'main'
      - '/publications'

The states I require are:

  • plid
  • menu_name
  • parent_link_path

I got the plid value from the database.

SELECT UUID FROM menu_link_content WHERE id IN (SELECT id FROM menu_link_content_data WHERE title = "publications");

I then used the result from that in the following SQL query.

SELECT mlid FROM menu_tree WHERE id =('menu_link_content:e7e5dcf2-110a-41ca-928d-5ff353a311fd');

The plid value expected in the migration is from source, not destination. As I don't have a source menu item, I am not sure how to add to the link to a specific menu parent.

Ideally, I would like to have the destination mlid value as part of the CSV data to assign each generated node to an existing parent menu item. Otherwise, I'm going to have about 600 nodes at the top level of the main menu and to figure out where they belong.

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.