0

Update: Turns out typos suck. But added an answer to this as well, in case anyone ever stumbles upon this...

I'm running into a bit of an issue using Migrate API. I thought I had a fairly simple use-case, but am unable to actually find an example for this particular instance.

I have a CSV I'm importing, utilizing the migrate_source_csv module. My migration was working just fine, but now I need to add a field_dealer_type field. This field is a multivalue checkbox. In the CSV, it's represented in a single dealer_type column, separated by commas (I've also tried other delimiters with no success).

A couple example rows of my CSV would look like:

id,name,city,dealer_type
1,Sample Location,Cool City,"trucks,motorcycles"
2,Another Location,Second City,trucks

The CSV is well-formatted, wrapping the dealer_type column in quotes when necessary.

However, I'm not able to get these to import properly into my nodes. I've verified the values through the CSV are valid options in the field definition as well (trucks, motorcycles).

I've started with the explode plugin, as other examples use that as well, but I know I'm missing a follow-up processing. I've seen example using Taxonomy and entity_generate, but that doesn't fit my use-case. I also have the migrate_plus module installed, for clarity.

langcode: en
status: true
dependencies: {  }
id: dealers_csv
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: default
label: 'Import Dealers'
source:
  plugin: csv
  path: sites/default/files/dealer_locations.csv
  delimiter: ','
  enclosure: '"'
  header_row_count: 1
  keys:
    - id
  column_names:
    -
      id: 'Unique Id'
    -
      name: 'Dealer Name'
    -
      city: City
    -
      dealer_type: 'Dealer Type'
process:
  title: name
  type:
    plugin: default_value
    default_value: dealer_location
  field_dealer_name: name
  field_dealer_city: city
  field_dealer_type:
    plugin: explode
    limit: 2
    delimeter: ','
    source: dealer_type
destination:
  plugin: 'entity:node'

0

Turns out typos can send you down a completely misguided rabbit hole!

Within the explode plugin, the property should be delimiter, not delimeter (incorrect spelling).

After that switch, things are working great. Yay.

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.