Im using the migrate module to import data from a json feed. Mostly work fine however, i require that each time the feed is imported , updated records in the source are updated in the destination if they exist.

Im struggling to find much information on this or more over explicitly how to implement this kind of functionality.

I have list my code to date and would really appreciate any input someone has on this. An example might be the same feed being imported but the aboutOurClient field updated in the source



class JSONMigration extends Migration {
   * A constructor 
  public function __construct() {


    $http_options = array();

    // define source definitions.... wont work with out this so hey ho
    $this->map = new MigrateSQLMap(
        'jobref' => array(
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,

    $fields = array(
      'jobref'                   => 'Job reference',
      'jobTitle'                 => 'Job title',
      'aboutOurClient'           => 'About the job',


    $json_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'json_migration') . '/';
    $items_url = $json_folder . 'PEsamplejson.json';

    $this->source = new MigrateSourceList(new ExampleListJSON($items_url),
      new ExampleItemJSON($items_url, array()), $fields);

    $options = array();

    $options = array('track_changes' => 1);
    $this->destination = new MigrateDestinationNode('jsontest', $options);
    //$this->systemOfRecord = Migration::DESTINATION;

    $this->addFieldMapping('field_jobref', 'jobref');
    $this->addFieldMapping('title'       , 'jobTitle');
    $this->addFieldMapping('body'        , 'aboutOurClient');


  public function prepareRow($row) {
     // i can remap/manipulate here if needs be ie date

  • AHA Seems i can effect this through drush drush mi --update {class name} Commented Feb 12, 2014 at 15:09

1 Answer 1


If you are using the Migrate UI, at the bottom of the page there is an Options slideout with the Update checkbox. If you are kicking off your migration programmatically then call prepareUpdate() before calling processImport().

$migration = Migration::getInstance($machine_name);
$result = $migration->processImport();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.