drupal 7迁移(和迁移附加)模块存在问题。未迁移的地址字段
我在Drupal 7数据迁移中遇到了一个问题,即我使用带有迁移附加项和地址字段的迁移模块。我的整个迁移工作正常,除了地址字段数据 似乎有很多老例子,但没有一个使用migrate支持的子字段表示法。我肯定错过了一些非常明显的东西。 非常感谢 这是我的密码:drupal 7迁移(和迁移附加)模块存在问题。未迁移的地址字段,drupal,drupal-7,drupal-modules,Drupal,Drupal 7,Drupal Modules,我在Drupal 7数据迁移中遇到了一个问题,即我使用带有迁移附加项和地址字段的迁移模块。我的整个迁移工作正常,除了地址字段数据 似乎有很多老例子,但没有一个使用migrate支持的子字段表示法。我肯定错过了一些非常明显的东西。 非常感谢 这是我的密码: class DOCInfoMigration extends JoomlaMigration { public function __construct() { parent::__construct(); $this->
class DOCInfoMigration extends JoomlaMigration {
public function __construct() {
parent::__construct();
$this->description = t('Loads early profiles data to DOCInfo profile');
/********* Source *********/
// MySQL database as source
$query = Database::getConnection('default', 'default')
->select('DOCInfo', 'u')
->fields('u', array('uid',
'first',
'last',
'phone',
'phonetype',
'dob',
'gender',
'membertype',
'year',
'make',
'model',
'new_used',
'tshirt_it',
'street',
'apt',
'city',
'state',
'zipcode'));
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationProfile2('doc_info'); // use machine name of profile
/*********** Map **********/
// Create a "map" which is used to translate primary keys*/
$this->map = new MigrateSQLMap($this->machineName,
array(
'uid' => array(
'type' => 'int',
'alias'=> 'u'
),
),
MigrateDestinationProfile2::getKeySchema()
);
/*********** Connect DOCInfo to user **********/
$this->addFieldMapping('uid', 'uid');
/******* Field mappings ******/
$this->addFieldMapping('language')->defaultValue('en');
$this->addFieldMapping('field_fname','first');
$this->addFieldMapping('field_fname:language')->defaultValue('en');
$this->addFieldMapping('field_lname','last');
$this->addFieldMapping('field_lname:language')->defaultValue('en');
$this->addFieldMapping('field_home_phone','phone');
$this->addFieldMapping('field_home_phone:language')->defaultValue('en');
$this->addFieldMapping('field_phone_type','phonetype');
$this->addFieldMapping('field_dob','dob');
$this->addFieldMapping('field_doc_gender','gender');
$this->addFieldMapping('field_doctype','membertype');
$this->addFieldMapping('field_docbikeyear','year');
$this->addFieldMapping('field_docmake','make');
$this->addFieldMapping('field_docmodel','model');
$this->addFieldMapping('field_docmodel:language')->defaultValue('en');
$this->addFieldMapping('field_docnewused','new_used');
$this->addFieldMapping('field_italian_t_shirt','tshirt_it');
$this->addFieldMapping('field_address:thoroughfare','street');
$this->addFieldMapping('field_address:premise','apt');
$this->addFieldMapping('field_address:locality','city');
$this->addFieldMapping('field_address:administrative_area','state');
$this->addFieldMapping('field_address:postal_code','zipcode');
/*** Unmapped destination fields ***/
$this->addUnmigratedDestinations(array('revision_uid',
'field_address',
'field_address:sub_administrative_area',
'field_address:dependent_locality',
'field_address:sub_premise',
'field_address:organisation_name',
'field_address:name_line',
'field_address:first_name',
'field_address:last_name',
'field_address:data',
'field_dob:timezone',
'field_dob:rrule',
'field_dob:to',));
}
AddressField需要一个国家/地区来知道要使用哪些子字段 尝试在其他地址字段映射之前添加此项:
$this->addFieldMapping('field_address', 'country')
->defaultValue('US');
(之后是
$this->addFieldMapping('field_address:thoroughfare','street');
$this->addFieldMapping('field_address:premise','apt');
$this->addFieldMapping('field_address:locality','city');
)