diff --git a/migrate_materio.company.inc b/migrate_materio.company.inc
index 13ad4ab3..6c7dffe2 100644
--- a/migrate_materio.company.inc
+++ b/migrate_materio.company.inc
@@ -14,8 +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'),
+ 'premise'=>'',
+ 'sub_premise'=>'',
);
$query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid');
@@ -79,7 +79,6 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$this->addFieldMapping(NULL, 'department_fr');
$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'),
@@ -106,13 +105,11 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$arguments = array(
'number' => array('source_field' => 'tel1'),
- // 'extension' => array('source_field' => 'ccode1_contact'),
);
$this->addFieldMapping('field_public_phone', 'ccode1')
->arguments($arguments);
$this->addFieldMapping(NULL, 'tel1');
- // $this->addFieldMapping(NULL, 'ccode1_contact');
$this->addFieldMapping(NULL, 'tel2');
$this->addFieldMapping(NULL, 'ccode2');
$this->addFieldMapping(NULL, 'tel3');
@@ -147,18 +144,20 @@ class MaterioCompanyMigration extends MaterioBasicMigration {
$cr->city = preg_replace('/\\n/', ' ', $cr->city);
$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->web_title = str_replace('http://', '', $cr->web);
$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);
-
-
- // if($cr->email_general != "")
- // $cr->email_sample .= ','.$cr->email_general;
+ $same_comp = taxonomy_get_term_by_name($cr->company);
+ if(count($same_comp))
+ $cr->company .= '-'.$cr->id_industrial;
$ccs = cck_phone_countrycodes();
$match = 0;
diff --git a/migrate_materio.materiau.inc b/migrate_materio.materiau.inc
index 56276ef7..8fea5200 100644
--- a/migrate_materio.materiau.inc
+++ b/migrate_materio.materiau.inc
@@ -19,6 +19,9 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
'description'=> t('en-fr description implemented on prepare'),
'nature'=> t('en-fr nature implemented on prepare'),
'language'=> t('en-fr langauge description, used in prepare'),
+ 'family' => '',
+ 'localisation' => '',
+ 'identifiant' => '',
);
$query = db_select(MIG_MAT_SRC_DB .'.product_id', 'pid');
@@ -86,6 +89,10 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
$this->addFieldMapping(null, 'quarity');
$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)
$infos['fr'] = $record;
- $infos['fr']->description .= "
technical : ".$infos['fr']->technical; // . "
usage".$infos['fr']->usage
+ if($infos['fr']->technical != '')
+ $infos['fr']->description .= "
technical : ".$infos['fr']->technical; // . "
usage".$infos['fr']->usage
$infos_en = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_en')
->condition('pif_en.id_locale', 1)
@@ -114,7 +122,8 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
foreach ($infos_en as $record)
$infos['en'] = $record;
- $infos['en']->description .= "
technical : ".$infos['en']->technical; // . "
usage".$infos['en']->usage
+ if($infos['en']->technical != '')
+ $infos['en']->description .= "
technical : ".$infos['en']->technical; // . "
usage".$infos['en']->usage
$cr->title = $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;
-
# parse companies
// dsm($cr->list_industrial, '-- $cr->list_industrial');
// dsm($cr->list_quarity, '$cr->list_quarity');
@@ -139,13 +147,16 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
$l = count($industrials);
for ($i=0; $i < $l; $i++) {
$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])
->distinct()->execute();
foreach ($result as $record) {
// dsm($record);
$company = trim($record->company);
+ $same_comp = taxonomy_get_term_by_name($company);
+ if(count($same_comp))
+ $company .= '-'.$record->id_industrial;
if($quarities[$i] == 'M'){
$companies_fab[] = $company;
@@ -158,28 +169,34 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
$cr->company_fab = implode(',', $companies_fab);
$cr->company_distrib = implode(',', $companies_distrib);
- //
- // preg_match('/^(\w)([^-]+)-(\d+)$/', $cr->id_materio, $matches);
+
+ preg_match('/^(\w)([^-]+)-(\d+)$/', $cr->id_materio, $matches);
// dsm($matches);
- //
+ $cr->family = $matches[1];
+ $cr->localisation = $matches[2];
+ $cr->identifiant = $matches[3];
+
return TRUE;
}
-
-
-
public function prepare($node, stdClass $row) {
// dsm('-- prepare --');
// dsm($node, '$node');
// dsm($row, '$row');
-
+
$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');
+ //
+ // }