id materio
materieau = fixe famille, identifiant (against computer filed) company = fixe multiple comp. with same names + misc Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
93b7db54fe
commit
9e85e7a105
@ -14,8 +14,8 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
|||||||
'id_industrial' => t('Industrial id from source'),
|
'id_industrial' => t('Industrial id from source'),
|
||||||
'department'=> t('en-fr department implemented on prepare'),
|
'department'=> t('en-fr department implemented on prepare'),
|
||||||
'language'=> t('en-fr langauge description, used in prepare'),
|
'language'=> t('en-fr langauge description, used in prepare'),
|
||||||
'premise'=>t('premise'),
|
'premise'=>'',
|
||||||
'sub_premise'=>t('sub_premise'),
|
'sub_premise'=>'',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid');
|
$query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid');
|
||||||
@ -79,7 +79,6 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
|||||||
$this->addFieldMapping(NULL, 'department_fr');
|
$this->addFieldMapping(NULL, 'department_fr');
|
||||||
|
|
||||||
$arguments = array(
|
$arguments = array(
|
||||||
// 'name_line' => array('source_field' => 'name'),
|
|
||||||
'thoroughfare' => array('source_field' => 'address'),
|
'thoroughfare' => array('source_field' => 'address'),
|
||||||
'premise' => array('source_field' => 'premise'),
|
'premise' => array('source_field' => 'premise'),
|
||||||
'sub_premise' => array('source_field' => 'sub_premise'),
|
'sub_premise' => array('source_field' => 'sub_premise'),
|
||||||
@ -106,13 +105,11 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
|||||||
|
|
||||||
$arguments = array(
|
$arguments = array(
|
||||||
'number' => array('source_field' => 'tel1'),
|
'number' => array('source_field' => 'tel1'),
|
||||||
// 'extension' => array('source_field' => 'ccode1_contact'),
|
|
||||||
);
|
);
|
||||||
$this->addFieldMapping('field_public_phone', 'ccode1')
|
$this->addFieldMapping('field_public_phone', 'ccode1')
|
||||||
->arguments($arguments);
|
->arguments($arguments);
|
||||||
|
|
||||||
$this->addFieldMapping(NULL, 'tel1');
|
$this->addFieldMapping(NULL, 'tel1');
|
||||||
// $this->addFieldMapping(NULL, 'ccode1_contact');
|
|
||||||
$this->addFieldMapping(NULL, 'tel2');
|
$this->addFieldMapping(NULL, 'tel2');
|
||||||
$this->addFieldMapping(NULL, 'ccode2');
|
$this->addFieldMapping(NULL, 'ccode2');
|
||||||
$this->addFieldMapping(NULL, 'tel3');
|
$this->addFieldMapping(NULL, 'tel3');
|
||||||
@ -147,18 +144,20 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
|
|||||||
$cr->city = preg_replace('/\\n/', ' ', $cr->city);
|
$cr->city = preg_replace('/\\n/', ' ', $cr->city);
|
||||||
|
|
||||||
$cr->department = array($cr->department_en, $cr->department_fr);
|
$cr->department = array($cr->department_en, $cr->department_fr);
|
||||||
// $cr->contact_quality = array($cr->contact_quality_en, $cr->contact_quality_fr);
|
|
||||||
// $cr->admin_quality = array($cr->admin_quality_en, $cr->admin_quality_fr);
|
|
||||||
$cr->language = array('en', 'fr');
|
$cr->language = array('en', 'fr');
|
||||||
|
|
||||||
$cr->web_title = str_replace('http://', '', $cr->web);
|
$cr->web_title = str_replace('http://', '', $cr->web);
|
||||||
$cr->web = 'http://' . $cr->web_title;
|
$cr->web = 'http://' . $cr->web_title;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO multiple company with same name
|
||||||
|
how to force new term creation ?
|
||||||
|
then how to recognize the right comp. with materieaux ?
|
||||||
|
*/
|
||||||
$cr->company = trim($cr->company);
|
$cr->company = trim($cr->company);
|
||||||
|
$same_comp = taxonomy_get_term_by_name($cr->company);
|
||||||
|
if(count($same_comp))
|
||||||
// if($cr->email_general != "")
|
$cr->company .= '-'.$cr->id_industrial;
|
||||||
// $cr->email_sample .= ','.$cr->email_general;
|
|
||||||
|
|
||||||
$ccs = cck_phone_countrycodes();
|
$ccs = cck_phone_countrycodes();
|
||||||
$match = 0;
|
$match = 0;
|
||||||
|
@ -19,6 +19,9 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
'description'=> t('en-fr description implemented on prepare'),
|
'description'=> t('en-fr description implemented on prepare'),
|
||||||
'nature'=> t('en-fr nature implemented on prepare'),
|
'nature'=> t('en-fr nature implemented on prepare'),
|
||||||
'language'=> t('en-fr langauge description, used in prepare'),
|
'language'=> t('en-fr langauge description, used in prepare'),
|
||||||
|
'family' => '',
|
||||||
|
'localisation' => '',
|
||||||
|
'identifiant' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query = db_select(MIG_MAT_SRC_DB .'.product_id', 'pid');
|
$query = db_select(MIG_MAT_SRC_DB .'.product_id', 'pid');
|
||||||
@ -86,6 +89,10 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
$this->addFieldMapping(null, 'quarity');
|
$this->addFieldMapping(null, 'quarity');
|
||||||
|
|
||||||
$this->addFieldMapping('field_onthologie')->defaultValue(null);
|
$this->addFieldMapping('field_onthologie')->defaultValue(null);
|
||||||
|
|
||||||
|
$this->addFieldMapping('field_famille', 'family');
|
||||||
|
$this->addFieldMapping('field_localisation', 'localisation');
|
||||||
|
$this->addFieldMapping('field_identifiant', 'identifiant');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -103,7 +110,8 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
foreach ($infos_fr as $record)
|
foreach ($infos_fr as $record)
|
||||||
$infos['fr'] = $record;
|
$infos['fr'] = $record;
|
||||||
|
|
||||||
$infos['fr']->description .= "<br />technical : ".$infos['fr']->technical; // . "<br />usage".$infos['fr']->usage
|
if($infos['fr']->technical != '')
|
||||||
|
$infos['fr']->description .= "<br />technical : ".$infos['fr']->technical; // . "<br />usage".$infos['fr']->usage
|
||||||
|
|
||||||
$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)
|
||||||
@ -114,7 +122,8 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
foreach ($infos_en as $record)
|
foreach ($infos_en as $record)
|
||||||
$infos['en'] = $record;
|
$infos['en'] = $record;
|
||||||
|
|
||||||
$infos['en']->description .= "<br />technical : ".$infos['en']->technical; // . "<br />usage".$infos['en']->usage
|
if($infos['en']->technical != '')
|
||||||
|
$infos['en']->description .= "<br />technical : ".$infos['en']->technical; // . "<br />usage".$infos['en']->usage
|
||||||
|
|
||||||
$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);
|
||||||
@ -126,7 +135,6 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
$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');
|
||||||
@ -139,13 +147,16 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
$l = count($industrials);
|
$l = count($industrials);
|
||||||
for ($i=0; $i < $l; $i++) {
|
for ($i=0; $i < $l; $i++) {
|
||||||
$result = db_select(MIG_MAT_SRC_DB .'.industrial_info', 'iif')
|
$result = db_select(MIG_MAT_SRC_DB .'.industrial_info', 'iif')
|
||||||
->fields('iif', array('company'))
|
->fields('iif', array('id_industrial', 'company'))
|
||||||
->condition('iif.id_industrial', $industrials[$i])
|
->condition('iif.id_industrial', $industrials[$i])
|
||||||
->distinct()->execute();
|
->distinct()->execute();
|
||||||
|
|
||||||
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($same_comp))
|
||||||
|
$company .= '-'.$record->id_industrial;
|
||||||
|
|
||||||
if($quarities[$i] == 'M'){
|
if($quarities[$i] == 'M'){
|
||||||
$companies_fab[] = $company;
|
$companies_fab[] = $company;
|
||||||
@ -158,28 +169,34 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|||||||
$cr->company_fab = implode(',', $companies_fab);
|
$cr->company_fab = implode(',', $companies_fab);
|
||||||
$cr->company_distrib = implode(',', $companies_distrib);
|
$cr->company_distrib = implode(',', $companies_distrib);
|
||||||
|
|
||||||
//
|
|
||||||
// preg_match('/^(\w)([^-]+)-(\d+)$/', $cr->id_materio, $matches);
|
preg_match('/^(\w)([^-]+)-(\d+)$/', $cr->id_materio, $matches);
|
||||||
// dsm($matches);
|
// dsm($matches);
|
||||||
//
|
$cr->family = $matches[1];
|
||||||
|
$cr->localisation = $matches[2];
|
||||||
|
$cr->identifiant = $matches[3];
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function prepare($node, stdClass $row) {
|
public function prepare($node, stdClass $row) {
|
||||||
// dsm('-- prepare --');
|
// dsm('-- prepare --');
|
||||||
// dsm($node, '$node');
|
// dsm($node, '$node');
|
||||||
// dsm($row, '$row');
|
// dsm($row, '$row');
|
||||||
|
|
||||||
$node->workflow = 4;
|
$node->workflow = 4;
|
||||||
|
|
||||||
// $node->field_public_email = array('und'=>array($row->email_contact));
|
$node->field_identifiant['und'][0]['value'] = $row->identifiant;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function complete($node, $row) {
|
||||||
|
// // dsm('-- complete --');
|
||||||
|
// // // Do what you need to do to
|
||||||
|
// // dsm($row, '$row');
|
||||||
|
// // dsm($node, '$node');
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user