简体   繁体   English

Drupal8-使用Drush和Migrate Source CSV模块以自定义内容类型导入内容

[英]Drupal8 - Import content in custom content-type with Drush and Migrate Source CSV module

I am trying to import a csv of "houses" with 480lines and 20columns in my frist Drupal8. 我正在尝试在第一篇Drupal8中导入包含480行和20列的“房屋”的csv。 I use this module . 我使用这个模块

I created a content-type "Group" with multiple custom fields in the Admin. 我在管理员中创建了具有多个自定义字段的内容类型“组”。

I create the config file as we can see on this page 我创建了配置文件,正如我们在此页面上看到的

I do not use Drush, i'm working with ftp transfer in the company server. 我不使用Drush,我正在公司服务器中进行ftp传输。 I don't know if I can do it using the drupal administration or another module. 我不知道我是否可以使用drupal管理或其他模块来做到这一点。

Right now the config file is not validated by the import, I fixed multiples erros but it still not ok. 现在,配置文件未通过导入验证,我修复了倍数错误,但仍然不行。 Do you have some examples of the config file ? 你有一些配置文件的例子吗? Alternative to Drush ? 替代Drush? Or another way to import CSV on D8 ? 还是在D8上导入CSV的另一种方法? Thank ! 谢谢 !

I managed to fixed it after few day and thank to the drupal.slack <3 This page had help me a lot. 几天后,我设法将其修复,并感谢drupal.slack <3此页面对我有很大帮助。 Also this video . 还有这个视频

STEP 1 : Config file. 步骤1:配置文件。 You'll find few examples. 您会发现一些示例。 Need to be imported on : admin/config/development/configuration/single/import with Type : "Migration" 需要在类型为“迁移”的admin / config / development / configuration / single / import上导入

This is mine 这是我的

  dependencies:
  module:
    - migrate_source_csv
id: groupimport1
label: 'Import groups'
migration_groups:
  - groupe
type: content_type
source:
  plugin: csv
  path: C:/wamp64/www/drupal/espacedomicile/themes/custom/espacedomicile/files/importgroup.csv
  header_row_count: 1
  keys:
    - field_groupe_numero
process:
  type:
    plugin: default_value
    default_value: groupe
  title: field_nom
  field_groupe_numero: field_groupe_numero
  field_nom: field_nom
  field_adresse: field_adresse
  field_groupe_code_postal: field_groupe_code_postal
  field_nom_commune: field_nom_commune
  field_groupe_communaute_de_com: field_groupe_communaute_de_com
  field_groupe_nombre_de_logements: field_groupe_nombre_de_logements
  field_groupe_nombre_collectif: field_groupe_nombre_collectif
  field_groupe_nombre_individuel: field_groupe_nombre_individuel
  field_groupe_equivalent_logement: field_groupe_equivalent_logement
  field_groupe_gaz: field_groupe_gaz
  field_groupe_gaz_chauffage_coll: field_groupe_gaz_chauffage_coll
  field_groupe_electrique: field_groupe_electrique
  field_groupe_niveau: field_groupe_niveau
  field_groupe_t1: field_groupe_t1
  field_groupe_t2: field_groupe_t2
  field_groupe_t3: field_groupe_t3
  field_groupe_t4: field_groupe_t4
  field_groupe_t5: field_groupe_t5
  field_groupe_t6: field_groupe_t6
  field_groupe_t7: field_groupe_t7
  field_groupe_garage: field_groupe_garage
  field_groupe_jardin_terrasse: field_groupe_jardin_terrasse
  field_groupe_parking: field_groupe_parking
  field_groupe_dependance: field_groupe_dependance
  field_groupe_local_associatif: field_groupe_local_associatif
  field_groupe_ascenseur: field_groupe_ascenseur
destination:
  plugin: entity:node

STEP 2 : I do not find alternative to drush then I transfered the site on local (with WAMP) and I install composer + drush (master last version for D8). 步骤2:我没有找到drush的替代方法,然后将站点转移到本地(使用WAMP),然后安装了composer + drush(D8的主版本)。 Then type the command on the recommended page above after having imported your config file. 导入配置文件后,在上面的推荐页面上键入命令。

drush ms
drush mi yourconfigid

I had problems because of my CSV file. 由于CSV文件,我遇到了问题。

  • I remplace ";" 我替换了“;” by ",". 通过“,”。
  • I also had to change the type of fields. 我还必须更改字段的类型。 Text values couldn't be matched with numercial type field. 文本值不能与数字类型字段匹配。

  • The path of my csv was an url. 我的csv的路径是一个URL。 I had to but a local one : C:/wamp64/www/drupal/espacedomicile/themes/custom/espacedomicile/files/importgroup.csv 我只需要一个本地的:C:/wamp64/www/drupal/espacedomicile/themes/custom/espacedomicile/files/importgroup.csv

Import done \\o/ what a journey to do somehting on D8 导入完成\\ o /在D8上完成任务的过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM