Using constant values in Drupal 8 Migrations

You, DrupalGoogle migration
Back

Using constant values is very common in migrations, it can be useful for adding content type machine name, concatenate values or any other default values. Sounds easy.

This example is from a recent project that I worked and what I'm trying to do is change the title so for example I get the title as Georgia and wanted to re-write as Georgia · Atlanta, GA

source:
  constants:
    city_separator: ', '
    title_separator: ' · '
process:
  city_name:
    plugin: concat
    source:
      - city
      - constants/city_separator
  chapter_name_new:
    plugin: concat
    source:
      - chapter_name
      - constants/title_separator
  title:
    plugin: concat
    source:
      - '@chapter_name_new'
      - '@city_name'
      - state
© Heshan Wanigasooriya.RSS

🍪 This site does not track you.