d8_custom_migrate icon indicating copy to clipboard operation
d8_custom_migrate copied to clipboard

Missing bundle for entity type node

Open laura-johnson opened this issue 8 years ago • 6 comments

Hi,

I'm trying to use your example to import nodes from a csv file.

I'm getting this from drush:

Missing bundle for entity type node [error] /core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:88

Do you know what I'm missing? My code is below. Thank you!

# Migration configuration for student content.
id: student_node
label: Students 
migration_tags:
  - CSV
source:
  plugin: csv
  # Full path to the file.
  path: /Users/rcmdev/Documents/Websites/8/modules/d8_custom_migrate/students.csv
  # The number of rows at the beginning which are not data.
  header_row_count: 1
  # These are the field names from the source file representing the key
  # uniquely identifying each game - they will be stored in the migration
  # map table as columns sourceid1, sourceid2, and sourceid3.
  keys:
    - sid
  # Here we identify the columns of interest in the source file. Each numeric
  # key is the 0-based index of the column. For each column, the key below
  # (e.g., "start_date") is the field name assigned to the data on import, to
  # be used in field mappings below. The value is a user-friendly string for
  # display by the migration UI.
  column_names:
    # So, here we're saying that the first field (index 0) on each line will
    # be stored in the start_date field in the Row object during migration, and
    # that name can be used to map the value below. "Date of game" will appear
    # in the UI to describe this field.
    0:
      sid: Identifier
    1:
      first_name: First name
    2:
      last_name: Last name

destination:
  plugin: entity:node
  type:
    plugin: default_value
    default_value: student
process:
  title: first_last
  field_sid: sid
  field_first_name: first_name
  field_last_name: last_name

laura-johnson avatar Feb 29 '16 19:02 laura-johnson

PS, I have created the 'student' content type in the GUI with the corresponding fields.

laura-johnson avatar Feb 29 '16 19:02 laura-johnson

The process section of the yml file is missing the bundle property a.k.a. type. Add the bundle and you'll be fine.

heddn avatar May 16 '16 15:05 heddn

To be precise:

  type:
    plugin: default_value
    default_value: [your node type]

Sutharsan avatar Feb 13 '17 15:02 Sutharsan

Open a PR and I'll merge this.

heddn avatar Feb 13 '17 15:02 heddn

I found this issue when searching for the 'Missing bundle for entity type node [error]' error message. So I don't know of the context of this code. But looking at migrate_plus.migration.migrate_csv.yml I think there is no need for changes. The process plugin is there:

process:
  # The content (node) type we are creating is 'people'.
  type:
    plugin: default_value
default_value: people

Sutharsan avatar Feb 14 '17 06:02 Sutharsan

I believe the OP just got confused that the bundle type must specified in the "process" section and not the "destination" section. I can see how this could be easily confused, as it seems more logical to specify the bundle type in the "destination".

Anyway @Sutharsan said, the codebase is already correct, and I suppose this issue can be closed.

https://github.com/heddn/d8_custom_migrate/blob/master/web/modules/custom/custom_migrate/config/install/migrate_plus.migration.migrate_csv.yml#L50-L54

jameswilson avatar Feb 19 '17 15:02 jameswilson