Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

class JSONMigration extends Migration { /**

  • A constructor */ public function __construct() {
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
  }
  
}

}

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

}

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 }

}

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
  }
  
}
deleted 1048 characters in body
Source Link

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

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',
  'location'                 => 'Location of job' ,
  'industry'                 => 'Job Industry',  
  'jobTitle'                 => 'Job title',
  'jobStatus'                => 'Status of the job',
  'updated'                  => 'Date job updated',
  'salary'                   => 'Salary of the job',
  'brandIdentifier'          => 'Brand intentifer ie MP , MPOAG', 
  'region'                   => 'Region job exists in',
  'backOfficeLocation'       => '', 
  'backOfficeRegion'         => '',
  'function'                 => 'Job function type',
  'jobtype'                  => 'job type perm/temp',
  'clientLogoURL'            => 'Logo of clilent advertising job',
  'intro'                    => 'Introduction to the job',
  'jobDescription'           => 'Description of the job',
  'theSuccessfulCandidate'   => 'What the candidate will be like',
  'aboutOurClient'           => 'About the client',
  'consultantName'           => 'Name of consultant dealing with applications',
  'consultantPhoneNo'        => 'Phone number of consulatnt',
  'consultantEmail'          => 'Email of consultant'job',
  'featured'                 => 'Featured 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');

 

I have list my code to date and would really appreciate any input someone has on this.

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',
  'location'                 => 'Location of job' ,
  'industry'                 => 'Job Industry',  
  'jobTitle'                 => 'Job title',
  'jobStatus'                => 'Status of the job',
  'updated'                  => 'Date job updated',
  'salary'                   => 'Salary of the job',
  'brandIdentifier'          => 'Brand intentifer ie MP , MPOAG', 
  'region'                   => 'Region job exists in',
  'backOfficeLocation'       => '', 
  'backOfficeRegion'         => '',
  'function'                 => 'Job function type',
  'jobtype'                  => 'job type perm/temp',
  'clientLogoURL'            => 'Logo of clilent advertising job',
  'intro'                    => 'Introduction to the job',
  'jobDescription'           => 'Description of the job',
  'theSuccessfulCandidate'   => 'What the candidate will be like',
  'aboutOurClient'           => 'About the client',
  'consultantName'           => 'Name of consultant dealing with applications',
  'consultantPhoneNo'        => 'Phone number of consulatnt',
  'consultantEmail'          => 'Email of consultant',
  'featured'                 => 'Featured 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');

 

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

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');

 
Source Link
Loading