added member_type on user migration
This commit is contained in:
parent
83b4c260bd
commit
6cc3844230
|
@ -105,6 +105,15 @@ process:
|
|||
# migration: d7_file
|
||||
# no_stub: true
|
||||
|
||||
field_member_type: member_type
|
||||
# plugin: static_map
|
||||
# source: member_type
|
||||
# default_value: 0
|
||||
# map:
|
||||
# 0:abo01-A
|
||||
# 1:abo01-B
|
||||
# 2:abo01-C
|
||||
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_allpublicfiles
|
||||
|
|
|
@ -134,6 +134,59 @@ class D7Users extends FieldableEntity {
|
|||
}
|
||||
}
|
||||
|
||||
// Member Type
|
||||
// check if aaf
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
if ( stripos($field_memo[0]['value'], 'membre aaf') !== false ){
|
||||
// drush_print($row->getSourceProperty('mail').' member_type: AAF');
|
||||
$row->setSourceProperty('member_type', 2);
|
||||
} else {
|
||||
// get the uber_cart order infos
|
||||
$query = $this->select('uc_orders', 'uco')
|
||||
->fields('uco', ['uid', 'order_id']);
|
||||
$query->leftJoin('uc_order_products', 'ucop', 'ucop.order_id=uco.order_id');
|
||||
$query->fields('ucop', ['model']);
|
||||
$query->condition('uid', $row->getSourceProperty('uid'));
|
||||
$query->condition('ucop.nid', 11849);
|
||||
$query->orderBy('uco.created', 'DESC');
|
||||
$orders = $query->execute()->fetchAll();
|
||||
|
||||
|
||||
if(count($orders)){
|
||||
$first_order = array_shift($orders);
|
||||
// drush_print($row->getSourceProperty('mail'));
|
||||
// drush_print(print_r($first_order, true));
|
||||
switch($first_order['model']){
|
||||
case "abo01-A":
|
||||
$member_type = 0;
|
||||
break;
|
||||
case "abo01-B":
|
||||
$member_type = 1;
|
||||
break;
|
||||
case "abo01-C":
|
||||
$member_type = 1;
|
||||
// add bad phone number to memo field
|
||||
$memo .= "#migration: multijoueurs \n";
|
||||
break;
|
||||
}
|
||||
if(isset($member_type)){
|
||||
// drush_print($row->getSourceProperty('mail').' member_type: '.$member_type);
|
||||
$row->setSourceProperty('member_type', $member_type);
|
||||
}
|
||||
|
||||
}
|
||||
// abo01-A 1 (web)
|
||||
// abo01-B 2 (web+showroom)
|
||||
// abo01-C 2 (web+showroom)
|
||||
}
|
||||
|
||||
// record migration errors in field_memo
|
||||
if(isset($memo)){
|
||||
$field_memo = $row->getSourceProperty('field_memo');
|
||||
$field_memo[0]['value'] .= "\n".$memo;
|
||||
$row->setSourceProperty('field_memo', $field_memo);
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue