Content Type - Node Migration from Drupal 7 to Drupal 8.
Here i am assuming that you have already gone through my previous blog related to Taxonomy Terms data migration. If not no problem too :)
Say we are developing a module as Custom Migration module with Module key as
"migrate_custom".
And yes we'll require to develop this for Drupal 8 :) by maintaining its standard.
migrate_custom will
have some dependencies with other modules like Migrate (migrate),
Migrate Plus (migrate_plus), Migrate Tools (migrate_tools), Migrate
Drupal ...
Lets start with
Node Migration with Code Example:
Our aim is to migrate all Node with content type=
Blog from d7.blog to d8.blog through a command like
$
drush migrate-import custom_blog --limit="500 items"
Ad per Drupal 8 standard we need a yml file to define everything and a php file to process that yml.
Here is there file/ folder structure
migrate_custom\src\Plugin\migrate\source\Blog.php
migrate_custom\config\install\migrate_plus.migration.custom_blog.yml
In .yml file we define four major parts. These are
id, source, process and destination.
Id is to identify this Migration process. Source is defined with the
data source. Process define basically the mapping of fields in between
destination and source.
id: custom_blog label: Blog node migration from Drupal 7 migration_group: custom dependencies: enforced: module: - migrate_custom source: plugin: custom_blog destination: plugin: entity:node bundle: blog process: # nid: nid # vid: vid type: type langcode: plugin: static_map bypass: true source: language map: und: und title: title uid: uid status: status created: created changed: changed promote: promote sticky: sticky 'body/format': plugin: static_map bypass: true source: body_format map: 1: plain_text 2: restricted_html 3: full_html 4: full_html 'body/value': body_value 'body/summary': body_summary field_highlight: fieldHighlightValue field_image: images |
Inside Blog.php class File extends SqlBase { } with four basic public functions these are
1. query() to fetch data from the source.
2. fields() to defined needed fields.
3. getIds() to get and return fid of File.
4. prepareRow() is basically to set source Property. Here we are settings uri.
A working copy of this Migration is available at
Github.
https://github.com/nirmalyamondal/Drupal-Modules/blob/master/migrate_custom/