5

How to skip (don't update) some fields from existing entity during import if this field already has a value? That for Drupal 8 with modules (migrate, migrate_plus and migrate_tools)

example of an yml I would like:

process:
  uid:
    -
      plugin: migration_lookup
      migration: users
      no_stub: true
      source: uid
  field_telephone: phone
  field_user_country: pays
  field_adresse/given_name: prenom
  field_adresse/family_name:
    -
      plugin: skip_on_notempty  \--> do not exist
      method: process
      source: \--> actuel value of 'field_adresse/family_name', How to get that ?
    -
      plugin: get
      source: nom
  • I need something similar, updating only certain fields. Nothing built in that I can find. this might be helpful, boylesoftware.com/blog/drupal-8-field-updates – troseman Nov 7 '17 at 22:12
  • Have you found a solution for this? I need to update the value of a text field body/value, but leave the existing summary body/summary as is. The overwrite_properties option does not work here, as it works only for whole fields, not for sub values of a single field. – Hudri Feb 14 '18 at 13:53
7

To import only a single field, or possibly multiple, use "overwrite_properties".

overwrite_properties: If the migration has specified a list of properties to be overwritten, clone the row with an empty set of destination values, and re-add only the specified properties.

destination:
  plugin: 'entity:node'
  overwrite_properties:
    - field_name

Source: Drupal\migrate\Plugin\migrate\destination

  • 3
    Wow, this is a hidden gem, your answer deserves to be marked "accepted". – marcvangend Mar 13 '18 at 12:20

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.