1

I'm trying to import a CSV File into Content Types and Paragraphs, using Migrate module (and mainly this tutorial : https://mtech-llc.com/blog/charlotte-leon/migration-csv-data-paragraphs).

For this I have created a custom module in modules/custom, and I added the .yml files in config/install.

Here's my two .yml (produit_epargne is for the Content Type, and epargne_support is for the Paragraph) :

dependencies:
  enforced:
    module:
      - produit_migration
id: produit_epargne
migration_group: produit_group
source:
  plugin: csv
  path: public://csv/test_import_csv_migrate.csv
  ids: 
    [id]
  header_row_count: 1
  delimiter: ';'
  fields:
    - 
      name: id
      label: id
    - 
      name: title
      label: title
    -
      name: field_referent
      label: field_referent
    -
      name: field_fiches_gamme
      label: field_fiches_gamme
    -
      name: field_date_mise_a_jour
      label: field_date_mise_a_jour
process:
  title: title
  field_referent: field_referent
  field_fiches_gamme: field_fiches_gamme
  field_date_mise_a_jour: 
    plugin: format_date
    from_format: Y-m-d
    to_format: Y-m-d
    source: field_date_mise_a_jour
    field_supports/target_id:
      -
        plugin: migration_lookup
        migration: epargne_supports
        no_stub: true
        source: id
      -
        plugin: extract
        index:
          - '0'
    field_supports/target_revision_id:
      -
        plugin: migration_lookup
        migration: epargne_supports
        no_stub: true
        source: id
      -
        plugin: extract
        index:
          - 1
destination:
  plugin: 'entity:node'
  default_bundle: produit_epargne
migration_dependencies:
  required: 
    - epargne_support
  optional: { }
dependencies:
  enforced:
    module:
      - produit_migration
id: epargne_support
migration_group: produit_group
source:
  plugin: csv
  path: public://csv/test_import_csv_migrate.csv
  header_row_count: 1
  delimiter: ';'
  ids: 
    [id]
  fields:
    -
      name: id
      label: id
    - 
      name: field_nb_fonds_euros
      label: field_nb_fonds_euros
    - 
      name: field_nb_fonds_thematiques
      label: field_nb_fonds_thematiques
    - 
      name: field_nb_support_fcpe
      label: field_nb_support_fcpe
    - 
      name: field_nb_support_uc
      label: field_nb_support_uc
process:
  field_nb_fonds_euros: field_nb_fonds_euros
  field_nb_fonds_thematiques: field_nb_fonds_thematiques
  field_nb_support_fcpe: field_nb_support_fcpe
  field_nb_support_uc: field_nb_support_uc
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: epargne_supports
migration_dependencies:
  required:
    - files
  optional: { }

But I have two major issues :

  1. First, the migration group produit_group is not recognized when I run : drush migrate:imports --group produit_group which is probably the source of the second issue
  2. Second, when I run drush migrate:imports produit_epargne, it only creates the content types withtout the paragraphs linked to it.

Does anybody see the problem in my code / configuration ?

4

1 Answer 1

0

Here are my thoughts for your code. Hope it helps!

#1 It should be drush migrate:import --group=produit_group instead of drush migrate:imports --group produit_group

#2 The paragraph migration name is wrong in the below mapping. It should be epargne_support instead of epargne_support

field_supports/target_id:
      -
        plugin: migration_lookup
        migration: epargne_supports
        no_stub: true
        source: id
      -
        plugin: extract
        index:
          - '0'
    field_supports/target_revision_id:
      -
        plugin: migration_lookup
        migration: epargne_supports
        no_stub: true
        source: id
      -
        plugin: extract
        index:
          - 1
2
  • Thanks for your response. Indeed I have misspelled my migrations name here, but I still have the same issues. No matter which command I use to run migrations group, I got this error : You must declare "ids" as a unique array of fields in your source settings.. In my understanding, it may say that no migration group of this name was find.
    – CanardPpc
    May 11, 2022 at 7:30
  • This error looks similar to this one - drupal.stackexchange.com/questions/297975/… May 11, 2022 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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