1

I'm a little bit new in Drupal but experienced in PHP. I would like to migrate data from CSV and assign to existing nodes in DB.

My question is about the possibility to match processing rows with existing data from the database.
I mean, I have CSV file with data and with foreign key called: SERVICE_ACTION and now I would like to assign that data to existing NODE which hasn’t SERVICE_ACTION key but has different KEY which is assigned to another specific entity with Service Action key. How can I get ID of that entity in migration script to assign?

Perhaps, I need target_id to assign newly created paragraph to the specific node. I’m not sure what I’m working bad.

langcode: en
status: true
dependencies:
  enforced:
    module:
      - xxx_migration
      - paragraphs
id: xxx_release_notes
migration_tags:
  - custom-migrate
  - soap-apis
migration_group: xxx_soap_api
label: 'xxx release notes'
source:
  plugin: csv
  data_fetcher_plugin: file
  path: modules/custom/xxx_migration/artifacts/releases_notes.csv
  header_row_count: 1
  keys:
    - id
  column_names:
    -
      id: 'Unique Id'
    -
      title: Title
    -
      body: 'Post body'
    -
      service_action_code: 'Service Action Code'
process:
  type:
    plugin: default_value
    default_value: people
  field_service_action_code:
    plugin: migration_lookup
    migration: xxx_release_notes
    source: service_action_code
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: release_note
migration_dependencies:
  required: {  }
optional: {  }

here is my CSV file:

id,title,body,service_action_code
1,TITLE,example body,PassengerDetailsRQ
2,TITLE2,example body2,ePaymentRQ
  • I don't know if it's possible to query the database from that. Maybe with something like a callback if that's possible? I'd to that myself taking github.com/GiantRobot/csvimport as a starting point. – leymannx Feb 15 '19 at 14:39
  • AFAIK the migrate module can not update entities it has not created itself. You'll have to create your own module/code, I don't think the Migrate module fits your use case. – Hudri Feb 15 '19 at 18:43
  • So you're wanting to look up a node entity id reference for field_service_action_code using the value service_action_code via a field value on the referenced node? – Shawn Conn Feb 16 '19 at 20:54
0

I don't know the exact answer. But maybe this information can get you on the right track. First the migration process has the ability to update earlier migrated entities, it does this with the help of high-water-marks and timestamps (see Drupal's documentation). Maybe you can do a trick to use this feature. Furthermore there is a lot of good documentation about the migration-process, I recommend this site, an extensive tutorial about the process in 31(!) steps/days, https://understanddrupal.com/31-days-of-migrations or https://www.phase2technology.com/blog/migration-making-it-all-work. Behind it some of the "Drupalstars" from the migration and comprehensibly written. Hope you find your answer there.

| improve this answer | |

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.