将图像从csv迁移到多值图像字段

时间:2018-12-29 16:26:22

标签: drupal migration drupal-8

我需要将csv文件导入产品节点类型。 我有使用当前方案的csv文件:

id | title   | category | image_url
-------------------------------------
1  | Title 1 | 1        | http://example.com/1.jpg,http://example.com/2.jpg
2  | Title 2 | 2        | http://example.com/3.jpg

如您所见,我有一个多值图像字段,并且在image_url列中还有多个图像。这是我的问题。如果csv文件中的单元格具有多个链接(用逗号分隔),则无法导入节点(和文件)。

在我发现需要为现场使用多个图像之前,我接下来要做: 我的csv模式是:

id | title   | category | image_url
-------------------------------------
1  | Title 1 | 1        | http://example.com/1.jpg
2  | Title 2 | 2        | http://example.com/2.jpg

并迁移.yml文件为:

id: catalog_products_files
label: 'Import catalog products files'
migration_group: catalog_products
source:
  plugin: csv
  path: public://csv/products.csv
  delimiter: ';'
  # enclosure: '"'
  header_row_count: 1
  # These are the field names from the source file representing the key
  # uniquely identifying each node - they will be stored in the migration
  # map table as columns sourceid1, sourceid2, and sourceid3.
  keys:
    - id
  column_names:
    0:
      id: 'Unique Id'
    1:
      title: 'Title'
    2:
      category: 'Product category'
    3:
      image_url: 'Image url'
  constants:
    status: 1
    uid: 1
    destination: 'public://migration-downloads/catalog/image.jpg'
ids:
  id:
    type: string
process:
  uri:
    -
      plugin: download
      source:
        - image_url
        - 'constants/destination'
      rename: true
    -
      plugin: skip_on_empty
      method: row
      message: 'Field downloaded_photo is missed'
  status: 'constants/status'
  uid: 'constants/uid'
destination:
  plugin: entity:file
migration_dependencies: {}
dependencies:
  enforced:
    module:
      - custom_csv_import
      - migrate_source_csv

所有导入都不错!如何从一行导入多张图像?

我正在使用Migrate Source CSV模块进行csv导入

0 个答案:

没有答案