XML-D8 Migration: Extending the migration capabilities by using available Process plugins
In our last blog post, XML-D8 Migration: Very basic migration by just using YML file, we have done very basic XML to Drupal 8 migration. In this blog post, we will extend the capabilities of that migration by using available Process plugins.
To add-on, we have added new fields like city, state, site url, site name, keywords, creation date to the XML file and now it looks like below,
We will be migrating city and state fields into place field in D8 by using concat process plugin. Site name and site url fields will be migrated to URL field in D8. Creation date field will be migrated to content creation date field in D8 using callback process plugin. Keywords field will be migrated to tags taxonomy field referenced in content type. For tags migration, we will be using explode process plugin and concept of pipeline.
We have added the new fields in page content type on D8 site and it looks like below,
Next we have added the mapping of these new fields in config/install/migrate_plus.migration.pages_content.yml file by using various process plugins. The mapping looks like below,
We have also used default_value process plugin at various places to assign default value to the fields in D8.
As we have made changes into .yml file and also want to migrate new fields so we have rolled back existing migrated data, re-installed the module and executed the migration like below,
The migration has been executed successfully and we got new data on D8 site. All the fields have been migrated as expected and looks like below,
The source code is also available on Git repository.
We have also added hook_uninstall() in migrate_xml_d8_custom.module file so that module can be uninstalled and enabled again after making changes in migration config .yml file without any issues.
To add-on, we have added new fields like city, state, site url, site name, keywords, creation date to the XML file and now it looks like below,
We will be migrating city and state fields into place field in D8 by using concat process plugin. Site name and site url fields will be migrated to URL field in D8. Creation date field will be migrated to content creation date field in D8 using callback process plugin. Keywords field will be migrated to tags taxonomy field referenced in content type. For tags migration, we will be using explode process plugin and concept of pipeline.
We have added the new fields in page content type on D8 site and it looks like below,
Next we have added the mapping of these new fields in config/install/migrate_plus.migration.pages_content.yml file by using various process plugins. The mapping looks like below,
We have also used default_value process plugin at various places to assign default value to the fields in D8.
As we have made changes into .yml file and also want to migrate new fields so we have rolled back existing migrated data, re-installed the module and executed the migration like below,
The migration has been executed successfully and we got new data on D8 site. All the fields have been migrated as expected and looks like below,
The source code is also available on Git repository.
We have also added hook_uninstall() in migrate_xml_d8_custom.module file so that module can be uninstalled and enabled again after making changes in migration config .yml file without any issues.





Comments