debug
- company : dispatch address filed in premise and sub_premise if more than 255 char - company : avoid and record on memo tel1 if number is more than 15 char - materiau : move product_info query in prepareRow() Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
@@ -14,6 +14,8 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
||||
'id_industrial' => t('Industrial id from source'),
|
||||
'department'=> t('en-fr department implemented on prepare'),
|
||||
'language'=> t('en-fr langauge description, used in prepare'),
|
||||
'premise'=>t('premise'),
|
||||
'sub_premise'=>t('sub_premise'),
|
||||
);
|
||||
|
||||
$query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid');
|
||||
@@ -79,6 +81,8 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
||||
$arguments = array(
|
||||
// 'name_line' => array('source_field' => 'name'),
|
||||
'thoroughfare' => array('source_field' => 'address'),
|
||||
'premise' => array('source_field' => 'premise'),
|
||||
'sub_premise' => array('source_field' => 'sub_premise'),
|
||||
'locality' => array('source_field' => 'city'),
|
||||
'postal_code' => array('source_field' => 'zip'),
|
||||
);
|
||||
@@ -86,6 +90,8 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
||||
->arguments($arguments);
|
||||
|
||||
$this->addFieldMapping(NULL, 'address');
|
||||
$this->addFieldMapping(NULL, 'premise');
|
||||
$this->addFieldMapping(NULL, 'sub_premise');
|
||||
$this->addFieldMapping(NULL, 'city');
|
||||
$this->addFieldMapping(NULL, 'zip');
|
||||
$this->addFieldMapping(NULL, 'country_fr');
|
||||
@@ -130,6 +136,14 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
||||
|
||||
public function prepareRow($cr) {
|
||||
$cr->address = preg_replace('/\\n/', ', ', $cr->address);
|
||||
if(strlen($cr->address) > 255){
|
||||
$adress = $cr->address;
|
||||
$cr->address = substr($adress, 0, 250);
|
||||
$cr->premise = substr($adress, 250, 500);
|
||||
$sub = substr($adress, 500, 750);
|
||||
$cr->sub_premise = $sub ? $sub : '';
|
||||
}
|
||||
|
||||
$cr->city = preg_replace('/\\n/', ' ', $cr->city);
|
||||
|
||||
$cr->department = array($cr->department_en, $cr->department_fr);
|
||||
@@ -148,32 +162,43 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
||||
|
||||
$ccs = cck_phone_countrycodes();
|
||||
$match = 0;
|
||||
$ccode1 = '';
|
||||
foreach ($ccs as $cc => $cc_values) {
|
||||
if('+'.$cr->ccode1 == $cc_values['code']){
|
||||
$cr->ccode1 = $cc;
|
||||
$ccode1 = $ccs[$cc];
|
||||
$match++;
|
||||
}
|
||||
if('+'.$cr->ccode2 == $cc_values['code']){
|
||||
$cr->ccode2 = $cc;
|
||||
$cr->ccode2 = $ccs[$cc];
|
||||
$match++;
|
||||
}
|
||||
if('+'.$cr->ccode3 == $cc_values['code']){
|
||||
$cr->ccode3 = $cc;
|
||||
$cr->ccode3 = $ccs[$cc];
|
||||
$match++;
|
||||
}
|
||||
|
||||
if($match == 4)
|
||||
if($match == 3)
|
||||
break;
|
||||
}
|
||||
|
||||
$cr->ccode1 = strlen($cr->ccode1) == 2 ? $cr->ccode1 : false;
|
||||
|
||||
if(($cr->tel1 != '' && !$cr->ccode1) || strlen($cr->tel1) > 15){
|
||||
$cr->tel1 = '';
|
||||
|
||||
$cc = is_array($ccode1) ? $ccode1['country'] . ' (' . $ccode1['code'] . ')' : '';
|
||||
$cr->memo .= "\n".'tel1 : '. $cc .' '. $cr->tel1;
|
||||
}
|
||||
|
||||
// do this because i don't know how to insert multiple phone fields
|
||||
// do this because i don't know how to insert multiple phone fields
|
||||
if($cr->tel2 != ''){
|
||||
$cc = cck_phone_countrycodes($cr->ccode2);
|
||||
$cr->memo .= "\n".'tel2 : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $cr->tel2;
|
||||
$cc = is_array($cr->ccode2) ? $cr->ccode2['country'] . ' (' . $cr->ccode2['code'] . ')' : '';
|
||||
$cr->memo .= "\n".'tel2 : '. $cc .' '. $cr->tel2;
|
||||
}
|
||||
if($cr->tel3 != ''){
|
||||
$cc = cck_phone_countrycodes($cr->ccode3);
|
||||
$cr->memo .= "\n".'tel3 : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $cr->tel3;
|
||||
$cc = is_array($cr->ccode3) ? $cr->ccode3['country'] . ' (' . $cr->ccode3['code'] . ')' : '';
|
||||
$cr->memo .= "\n".'tel3 : '. $cc .' '. $cr->tel3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user