Migrating from CSV

Last updated on
16 October 2018

Migrate Source CSV is used to provide the source plugin that handles CSV files. For information on how to write a yml file to read a CSV file see Migrating data from a CSV source.

Commerce Migrate provides two type of CSV migrations. One is from a generic CSV file and an example is provided in the module, CSV Example. The other type is using the CSV output from other Commerce providers, like WooCommerce, and examples of these are in modules named after the source, e.g. woocommerce. The later types are discussed here.

The CSV migrations provided by Commerce Migrate use a test file created by the standard export tool provided by the source system, for example WooCommerce. The migration contains the path to the test file and that needs to be changed to the path and filename of your CSV file. This can be done in a custom module in a hook_migration_plugins_alter.

In this example the source path to the CSV file in the wc_category.yml migrations is changed to 'public://commerce-export.csv'

function hook_migration_plugins_alter(array &$migrations) {
  foreach ($migrations as $key => &$migration) {
    if ($migration['id'] === 'wc_category') {;
      $migration['source']['path'] = 'public://commerce-export.csv'';
    };
  }
}

Help improve this page

Page status: No known problems

You can: