I try to import content from a
.csv file into article nodes of a fresh D9 install using
Migrate csv source and
Migrate File (extended)
My article content type has a
field_article_media_image expecting a media image item.
When I run the migration, the articles are created correctly BUT the
field_article_media_image is still empty. I see the image has been imported in the filesystem, but created as a file, not as a media item (not present in the media tab) and it is not linked to the article.
//import-articles.yml id: import_articles label: Import articles migration_group: import_articles_group destination: plugin: entity:node source: constants: DESTINATION_PATH: 'public://migrations/articles/images/' plugin: 'csv' path: 'migrations/articles/articles.csv' delimiter: ';' enclosure: '"' header_offset: 0 ids: - id fields: 0: name: id label: 'Id' 1: name: title label: 'Title' 2: name: body label: 'Body' 3: name: field_article_media_image label: 'Image' process: title: title body/value: body body/format: plugin: default_value default_value: 'basic_html' field_article_media_image: - plugin: image_import source: field_article_media_image destination: constants/DESTINATION_PATH title: title skip_on_error: true - plugin: log type: plugin: default_value default_value: article
The log gives no error. Am I missing something or am I doing something wrong?
After what @Joseph commented, I tried this code:
... field_article_media_image: source: field_article_media_image plugin: entity_lookup entity_type: media bundle: image bundle_key: bundle value_key: 'name' access_check: 0 ...
Everything is working now, I think
value_key needed quotes, and maybe
access_check had to be set to false.