You are here

public function PartyB2BOrganizationProfile2Migration::__construct in Party 8.2

Same name and namespace in other branches
  1. 7 starterkits/party_starterkit_b2b/party_starterkit_b2b_migrate/party_starterkit_b2b_migrate_organizations.inc \PartyB2BOrganizationProfile2Migration::__construct()

Set up the migration.

File

starterkits/party_starterkit_b2b/party_starterkit_b2b_migrate/party_starterkit_b2b_migrate_organizations.inc, line 40
Support for migrate module

Class

PartyB2BOrganizationProfile2Migration

Code

public function __construct() {
  parent::__construct();
  $this->description = t('Migration of organizations from CSV to Profile2 entities.');
  $this->map = new MigrateSQLMap($this->machineName, array(
    'org_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ), MigrateDestinationProfile2::getKeySchema());
  $this->source = new MigrateSourceCSV(__DIR__ . '/org.csv', $this
    ->csvcolumns(), array(
    'header_rows' => 1,
  ));

  // MigrateDestination
  $this->destination = new MigrateDestinationProfile2('party_org');

  // Field Mappings
  $this
    ->addFieldMapping('uid')
    ->defaultValue(0);
  $this
    ->addFieldMapping('party_org_name', 'org_name');
  $this
    ->addFieldMapping('party_org_phone', 'org_phone');
  $this
    ->addFieldMapping('party_org_web', 'org_web');
  $this
    ->addFieldMapping('party_org_email', 'org_email');

  // Map the addressfield components.
  $address_arguments = array(
    'thoroughfare' => array(
      'source_field' => 'org_address1',
    ),
    'premise' => array(
      'source_field' => 'org_address2',
    ),
    'locality' => array(
      'source_field' => 'org_city',
    ),
    'administrative_area' => array(
      'source_field' => 'org_state',
    ),
    'postal_code' => array(
      'source_field' => 'org_zip',
    ),
  );
  $this
    ->addFieldMapping('party_org_address', 'org_country')
    ->arguments($address_arguments);
}