0

I want to import companies with csv into Drupal 8 with migrate_source_csv module.

CSV:

company_name,company_categories,company_size
"Dummy Name","Category 1";"Category 2","2 people"

How to accomplish? Do I need an other plugin: explode?

    process:
      field_categories:
        plugin: explode
           source: company_categories
           delimiter: ';'
        plugin: entity_generate
        source: company_categories

I also found this: https://www.drupal.org/node/2129651#handling_multiple

0

I found it myself. This is working for me:

process:
  title: title
  body: body
  field_company:
    -
      plugin: explode
      source: categories
      limit: 100
      delimiter: ;
    -
      plugin: entity_generate
      ignore_case: true
  type:
    plugin: default_value
    default_value: company

and a CSV like this:

id,title,body,categories
6,company,body text,"cat1, some text;cat1, some other text"
  • This code will also create taxonomy term under categories. Please check if this code is creating the same term twice – logeshvaran Oct 20 '17 at 11:48
  • Yes, it is creating a taxonomy term under categories, if it does not exists. I would suggest to add ignore_case: true to avoid duplicates? – user3086053 Oct 23 '17 at 13:19
  • yes. you are right – logeshvaran Oct 23 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.