bug fixing

ccode
homonym companies terms
tel to long set to memo instead of phone field

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy 2012-05-21 17:50:22 +02:00
parent 9e85e7a105
commit 18982b6700
5 changed files with 46 additions and 23 deletions

View File

@ -75,6 +75,8 @@ class MaterioIndustrialAdminUserMigration extends MaterioBasicMigration {
return false; return false;
$cr->company = trim($cr->company); $cr->company = trim($cr->company);
if(count(taxonomy_get_term_by_name($cr->company.'-'.$cr->id_industrial)))
$cr->company .= '-'.$cr->id_industrial;
$cr->memo = "#admin"; $cr->memo = "#admin";
@ -196,11 +198,11 @@ class MaterioIndustrialAdminProfile2Migration extends MaterioBasicMigration {
$ccs = cck_phone_countrycodes(); $ccs = cck_phone_countrycodes();
$match = 0; $match = 0;
foreach ($ccs as $cc => $cc_values) { foreach ($ccs as $cc => $cc_values) {
if('+'.$cr->ccode1_admin == $cc_values['code']){ if('+'.preg_replace('/^\+/', '', $cr->ccode1_admin) == $cc_values['code']){
$cr->ccode1_admin = $cc; $cr->ccode1_admin = $cc;
$match++; $match++;
} }
if('+'.$cr->ccode2_admin == $cc_values['code']){ if('+'.preg_replace('/^\+/', '', $cr->ccode2_admin) == $cc_values['code']){
$cr->ccode2_admin = $cc; $cr->ccode2_admin = $cc;
$match++; $match++;
} }

View File

@ -61,7 +61,7 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
); );
// Make the mappings // Make the mappings
$this->addFieldMapping('language')->defaultValue(''); $this->addFieldMapping('language')->defaultValue('en');
$this->addFieldMapping('is_new')->defaultValue(TRUE); $this->addFieldMapping('is_new')->defaultValue(TRUE);
$this->addFieldMapping('created', 'date_creation'); $this->addFieldMapping('created', 'date_creation');
$this->addFieldMapping('changed', 'date_modif'); $this->addFieldMapping('changed', 'date_modif');
@ -95,9 +95,9 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$this->addFieldMapping(NULL, 'zip'); $this->addFieldMapping(NULL, 'zip');
$this->addFieldMapping(NULL, 'country_fr'); $this->addFieldMapping(NULL, 'country_fr');
$arguments = MigrateLinkFieldHandler::arguments(array('source_field' => 'web_title')); // $arguments = MigrateLinkFieldHandler::arguments(array('source_field' => 'web_title'));
$this->addFieldMapping('field_website', 'web') $this->addFieldMapping('field_website', 'web');
->arguments($arguments); // ->arguments($arguments);
$this->addFieldMapping('body')->defaultValue(''); $this->addFieldMapping('body')->defaultValue('');
$this->addFieldMapping('field_infos_from_company')->defaultValue(''); $this->addFieldMapping('field_infos_from_company')->defaultValue('');
@ -139,6 +139,9 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$cr->premise = substr($adress, 250, 500); $cr->premise = substr($adress, 250, 500);
$sub = substr($adress, 500, 750); $sub = substr($adress, 500, 750);
$cr->sub_premise = $sub ? $sub : ''; $cr->sub_premise = $sub ? $sub : '';
}else{
$cr->premise = '';
$cr->sub_premise = '';
} }
$cr->city = preg_replace('/\\n/', ' ', $cr->city); $cr->city = preg_replace('/\\n/', ' ', $cr->city);
@ -146,8 +149,7 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$cr->department = array($cr->department_en, $cr->department_fr); $cr->department = array($cr->department_en, $cr->department_fr);
$cr->language = array('en', 'fr'); $cr->language = array('en', 'fr');
$cr->web_title = str_replace('http://', '', $cr->web); $cr->web = str_replace('http://', '', $cr->web);
$cr->web = 'http://' . $cr->web_title;
/* /*
TODO multiple company with same name TODO multiple company with same name
@ -156,8 +158,11 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
*/ */
$cr->company = trim($cr->company); $cr->company = trim($cr->company);
$same_comp = taxonomy_get_term_by_name($cr->company); $same_comp = taxonomy_get_term_by_name($cr->company);
if(count($same_comp)) if(count($same_comp)){
$cr->company .= '-'.$cr->id_industrial; $cr->company .= '-'.$cr->id_industrial;
$cr->memo .= "\n".'#multiple-term';
}
$ccs = cck_phone_countrycodes(); $ccs = cck_phone_countrycodes();
$match = 0; $match = 0;

View File

@ -74,7 +74,9 @@ class MaterioIndustrialContactUserMigration extends MaterioBasicMigration {
if($cr->email_contact == "") if($cr->email_contact == "")
return false; return false;
$cr->company = trim($cr->company); $cr->company = trim($cr->company);
if(count(taxonomy_get_term_by_name($cr->company.'-'.$cr->id_industrial)))
$cr->company .= '-'.$cr->id_industrial;
$cr->memo = "#contact"; $cr->memo = "#contact";
@ -201,11 +203,11 @@ class MaterioIndustrialContactProfile2Migration extends MaterioBasicMigration {
$ccs = cck_phone_countrycodes(); $ccs = cck_phone_countrycodes();
$match = 0; $match = 0;
foreach ($ccs as $cc => $cc_values) { foreach ($ccs as $cc => $cc_values) {
if('+'.$cr->ccode1_contact == $cc_values['code']){ if('+'.preg_replace('/^\+/', '', $cr->ccode1_contact) == $cc_values['code']){
$cr->ccode1_contact = $cc; $cr->ccode1_contact = $cc;
$match++; $match++;
} }
if('+'.$cr->ccode2_contact == $cc_values['code']){ if('+'.preg_replace('/^\+/', '', $cr->ccode2_contact) == $cc_values['code']){
$cr->ccode2_contact = $cc; $cr->ccode2_contact = $cc;
$match++; $match++;
} }
@ -213,11 +215,24 @@ class MaterioIndustrialContactProfile2Migration extends MaterioBasicMigration {
break; break;
} }
if(strlen($cr->ccode1_contact) > 2 && $cr->tel1_contact != "" ){
$cr->memo .= "\n".'tel1 contact : '. $cr->ccode1_contact .' '. $cr->tel1_contact;
$cr->tel1_contact = NULL;
$cr->ccode1_contact = NULL;
}
if(strlen($cr->tel1_contact) > 15){
$cc = cck_phone_countrycodes($cr->ccode1_contact);
$cr->memo .= "\n".'tel1 contact : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $cr->tel1_contact;
$cr->tel1_contact = NULL;
$cr->ccode1_contact = NULL;
}
if($cr->tel2_contact != ''){ if($cr->tel2_contact != ''){
$cc = cck_phone_countrycodes($cr->ccode2_contact); $cc = cck_phone_countrycodes($cr->ccode2_contact);
$cr->memo .= "\n".'tel2 contact : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $cr->tel2_contact; $cr->memo .= "\n".'tel2 contact : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $cr->tel2_contact;
} }
// dsm($cr, '- - - - $cr - - - -'); // dsm($cr, '- - - - $cr - - - -');
return TRUE; return TRUE;

View File

@ -61,7 +61,7 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
$this->addFieldMapping('status')->defaultValue(1); $this->addFieldMapping('status')->defaultValue(1);
$this->addFieldMapping('promote')->defaultValue(0); $this->addFieldMapping('promote')->defaultValue(0);
$this->addFieldMapping('sticky')->defaultValue(0); $this->addFieldMapping('sticky')->defaultValue(0);
$this->addFieldMapping('language')->defaultValue('fr'); $this->addFieldMapping('language')->defaultValue('en');
$this->addFieldMapping('title', 'title'); $this->addFieldMapping('title', 'title');
$this->addFieldMapping('field_memo', 'memo'); $this->addFieldMapping('field_memo', 'memo');
@ -100,7 +100,7 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
public function prepareRow($cr){ public function prepareRow($cr){
// dsm($cr); // dsm($cr);
# parse product infos # get product infos FR
$infos_fr = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_fr') $infos_fr = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_fr')
->condition('pif_fr.id_locale', 2) ->condition('pif_fr.id_locale', 2)
->condition('pif_fr.id_product', $cr->id_product) ->condition('pif_fr.id_product', $cr->id_product)
@ -112,7 +112,8 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
if($infos['fr']->technical != '') if($infos['fr']->technical != '')
$infos['fr']->description .= "<br />technical : ".$infos['fr']->technical; // . "<br />usage".$infos['fr']->usage $infos['fr']->description .= "<br />technical : ".$infos['fr']->technical; // . "<br />usage".$infos['fr']->usage
# get product infos EN
$infos_en = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_en') $infos_en = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_en')
->condition('pif_en.id_locale', 1) ->condition('pif_en.id_locale', 1)
->condition('pif_en.id_product', $cr->id_product) ->condition('pif_en.id_product', $cr->id_product)
@ -124,17 +125,17 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
if($infos['en']->technical != '') if($infos['en']->technical != '')
$infos['en']->description .= "<br />technical : ".$infos['en']->technical; // . "<br />usage".$infos['en']->usage $infos['en']->description .= "<br />technical : ".$infos['en']->technical; // . "<br />usage".$infos['en']->usage
# set product infos
$cr->title = $infos['fr']->name; $cr->title = $infos['fr']->name;
$cr->name = array($infos['en']->name, $infos['fr']->name); $cr->name = array($infos['en']->name, $infos['fr']->name);
$cr->description = array($infos['en']->description, $infos['fr']->description); $cr->description = array($infos['en']->description, $infos['fr']->description);
$cr->nature = array($infos['en']->nature, $infos['fr']->nature); $cr->nature = array($infos['en']->nature, $infos['fr']->nature);
$cr->language = array('en', 'fr'); $cr->language = array('en', 'fr');
#record keywords on memo # record keywords on memo
$cr->memo .= ($cr->memo != '' ? "\n\n" : '') . $infos['fr']->keywords; $cr->memo .= ($cr->memo != '' ? "\n\n" : '') . $infos['fr']->keywords;
# parse companies # parse companies
// dsm($cr->list_industrial, '-- $cr->list_industrial'); // dsm($cr->list_industrial, '-- $cr->list_industrial');
// dsm($cr->list_quarity, '$cr->list_quarity'); // dsm($cr->list_quarity, '$cr->list_quarity');
@ -154,9 +155,8 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
foreach ($result as $record) { foreach ($result as $record) {
// dsm($record); // dsm($record);
$company = trim($record->company); $company = trim($record->company);
$same_comp = taxonomy_get_term_by_name($company); if(count(taxonomy_get_term_by_name($company.'-'.$record->id_industrial)))
if(count($same_comp)) $company .= '-'.$record->id_industrial;
$company .= '-'.$record->id_industrial;
if($quarities[$i] == 'M'){ if($quarities[$i] == 'M'){
$companies_fab[] = $company; $companies_fab[] = $company;

View File

@ -66,7 +66,6 @@ class MaterioIndustrialSampleUserMigration extends MaterioBasicMigration {
$this->addFieldMapping('field_company', 'company'); $this->addFieldMapping('field_company', 'company');
} }
public function prepareRow($cr) { public function prepareRow($cr) {
@ -74,6 +73,8 @@ class MaterioIndustrialSampleUserMigration extends MaterioBasicMigration {
return false; return false;
$cr->company = trim($cr->company); $cr->company = trim($cr->company);
if(count(taxonomy_get_term_by_name($cr->company.'-'.$cr->id_industrial)))
$cr->company .= '-'.$cr->id_industrial;
$cr->memo = "#sample"; $cr->memo = "#sample";