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
cheers
Steve
class JSONMigration extends Migration {
/**
* A constructor
*/
public function __construct() {
parent::__construct(MigrateGroup::getInstance('json_migration'));
$http_options = array();
// define source definitions.... wont work with out this so hey ho
$this->map = new MigrateSQLMap(
$this->machineName,
array(
'jobref' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
MigrateDestinationNode::getKeySchema()
);
$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
}
}