|
@@ -14,38 +14,20 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
'id_product' => t('Materiau id from source'),
|
|
|
'company_fab'=>t('company_fab'),
|
|
|
'company_distrib'=>t('company_distrib'),
|
|
|
- // 'name'=> t('en-fr name implemented on prepare'),
|
|
|
- // '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'),
|
|
|
+ 'title'=>t('title'),
|
|
|
+ 'name'=> t('en-fr name implemented on prepare'),
|
|
|
+ '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'),
|
|
|
);
|
|
|
|
|
|
$query = db_select(MIG_MAT_SRC_DB .'.product_id', 'pid');
|
|
|
|
|
|
$query->join(MIG_MAT_SRC_DB .'.product_industrial', 'pind', 'pind.id_product = pid.id_product');
|
|
|
-
|
|
|
- // $industrial_query = db_select(MIG_MAT_SRC_DB .'.industrial_info', 'iif_select')
|
|
|
- // ->fields('iif_select', array('id_industrial', 'company'))->distinct();
|
|
|
- // $query->join($industrial_query, 'iif', 'iif.id_industrial = pind.id_industrial');
|
|
|
|
|
|
-
|
|
|
- // WARNING ! product_info is double langauge + duplicate -> 4 rows each product
|
|
|
- // $pif_fr_query = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_fr_select')
|
|
|
- // //->fields('pif_fr_select')// , array('id_product') //, 'name', 'nature', 'description', 'usage', 'technical', 'keywords',
|
|
|
- // ->condition('pif_fr_select.id_locale', 2)->distinct();
|
|
|
- // $pif_fr_query->addField('pif_fr_select', 'id_product', 'id_product');
|
|
|
- // $query->join($pif_fr_query, 'pif_fr', 'pif_fr.id_product = pid.id_product');
|
|
|
-
|
|
|
- // $pif_en_query = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_en_select')
|
|
|
- // ->fields('pif_en_select')//, array('id_product') //, 'name', 'nature', 'description', 'usage', 'technical', 'keywords',
|
|
|
- // ->condition('pif_en_select.id_locale', 1)->distinct();
|
|
|
- // // $pif_en_query->addField('pif_en_select', 'name', 'name_en');
|
|
|
- // $query->join($pif_en_query, 'pif_en', 'pif_en.id_product = pid.id_product');
|
|
|
-
|
|
|
$query
|
|
|
->fields('pid', array('id_product', 'id_materio', 'status', 'memo', 'source', 'date_creation', 'date_modif'))
|
|
|
->fields('pind', array('id_industrial', 'quarity'));
|
|
|
- // ->fields('iff', array('company'))
|
|
|
|
|
|
$query->addExpression('GROUP_CONCAT(DISTINCT pind.id_industrial)','list_industrial');
|
|
|
$query->addExpression('GROUP_CONCAT(pind.quarity)','list_quarity');
|
|
@@ -54,21 +36,6 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
->orderBy('pid.id_product', 'DESC')
|
|
|
->groupBy('pid.id_product');
|
|
|
|
|
|
- //'name', 'nature', 'description', 'usage', 'technical', 'keywords'
|
|
|
- // $query->addField('pif_fr', 'name', 'name_fr');
|
|
|
- // $query->addField('pif_fr', 'nature', 'nature_fr');
|
|
|
- // $query->addField('pif_fr', 'description', 'description_fr');
|
|
|
- // $query->addField('pif_fr', 'usage', 'usage_fr');
|
|
|
- // $query->addField('pif_fr', 'technical', 'technical_fr');
|
|
|
- // $query->addField('pif_fr', 'keywords', 'keywords_fr');
|
|
|
- //
|
|
|
- // $query->addField('pif_en', 'name', 'name_en');
|
|
|
- // $query->addField('pif_en', 'nature', 'nature_en');
|
|
|
- // $query->addField('pif_en', 'description', 'description_en');
|
|
|
- // $query->addField('pif_en', 'usage', 'usage_en');
|
|
|
- // $query->addField('pif_en', 'technical', 'technical_en');
|
|
|
- // $query->addField('pif_en', 'keywords', 'keywords_en');
|
|
|
-
|
|
|
$this->source = new MigrateSourceSQL($query, $source_fields);
|
|
|
$this->destination = new MigrateDestinationNode('materiau');
|
|
|
|
|
@@ -91,29 +58,25 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
$this->addFieldMapping('status')->defaultValue(1);
|
|
|
$this->addFieldMapping('promote')->defaultValue(0);
|
|
|
$this->addFieldMapping('sticky')->defaultValue(0);
|
|
|
+ $this->addFieldMapping('language')->defaultValue('fr');
|
|
|
|
|
|
- // $this->addFieldMapping('title', 'name_fr');
|
|
|
+ $this->addFieldMapping('title', 'title');
|
|
|
$this->addFieldMapping('field_memo', 'memo');
|
|
|
|
|
|
- // $this->addFieldMapping('title_field', 'name');
|
|
|
- // $this->addFieldMapping('title_field:language', 'language');
|
|
|
- // $this->addFieldMapping(NULL, 'name_en');
|
|
|
- // $this->addFieldMapping(NULL, 'name_fr');
|
|
|
+ $this->addFieldMapping('title_field', 'name');
|
|
|
+ $this->addFieldMapping('title_field:language', 'language');
|
|
|
|
|
|
- // see on prepareRow()
|
|
|
- // $this->addFieldMapping('field_description', 'description');
|
|
|
- // $this->addFieldMapping('field_description:language', 'language');
|
|
|
- // $this->addFieldMapping(NULL, 'description_en');
|
|
|
- // $this->addFieldMapping(NULL, 'description_fr');
|
|
|
+ $this->addFieldMapping('field_description', 'description');
|
|
|
+ $this->addFieldMapping('field_description:language', 'language');
|
|
|
+ $this->addFieldMapping('field_description:format')->defaultValue('filtred_html');
|
|
|
|
|
|
- // $this->addFieldMapping('field_nature_titre', 'nature');
|
|
|
- // $this->addFieldMapping('field_nature_titre:language', 'language');
|
|
|
- // $this->addFieldMapping(NULL, 'nature_en');
|
|
|
- // $this->addFieldMapping(NULL, 'nature_fr');
|
|
|
+ $this->addFieldMapping('field_nature_titre', 'nature');
|
|
|
+ $this->addFieldMapping('field_nature_titre:language', 'language');
|
|
|
|
|
|
$this->addFieldMapping('field_company_fab', 'company_fab');
|
|
|
$this->addFieldMapping('field_company_fab:create_term')->defaultValue(false);
|
|
|
$this->addFieldMapping('field_company_distrib', 'company_distrib');
|
|
|
+ $this->addFieldMapping('field_company_distrib:create_term')->defaultValue(false);
|
|
|
|
|
|
$this->addFieldMapping('pathauto')->defaultValue(1);
|
|
|
$this->addFieldMapping('comment')->defaultValue(0);
|
|
@@ -130,26 +93,43 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
public function prepareRow($cr){
|
|
|
// dsm($cr);
|
|
|
|
|
|
- // $result = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_fr_select')
|
|
|
- // ->fields('pif_fr_select' , array('name', 'nature', 'description'))// , 'usage', 'technical', 'keywords',
|
|
|
- // ->condition('pif_fr_select.id_locale', 2)
|
|
|
- // ->condition('pif_fr_select.id_product', $cr->id_product)
|
|
|
- // ->distinct();//->exectute();
|
|
|
+ # parse product infos
|
|
|
+ $infos_fr = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_fr')
|
|
|
+ ->condition('pif_fr.id_locale', 2)
|
|
|
+ ->condition('pif_fr.id_product', $cr->id_product)
|
|
|
+ ->fields('pif_fr' , array('name', 'nature', 'description', 'technical', 'keywords'))//, 'usage'
|
|
|
+ ->distinct()->execute();
|
|
|
+
|
|
|
+ foreach ($infos_fr as $record)
|
|
|
+ $infos['fr'] = $record;
|
|
|
|
|
|
- // $prod_infos_fr = $result->fetchAll();
|
|
|
+ $infos['fr']->description .= "<br />technical : ".$infos['fr']->technical; // . "<br />usage".$infos['fr']->usage
|
|
|
|
|
|
- // dsm($result->__toString(), '$query to string');
|
|
|
+ $infos_en = db_select(MIG_MAT_SRC_DB .'.product_info', 'pif_en')
|
|
|
+ ->condition('pif_en.id_locale', 1)
|
|
|
+ ->condition('pif_en.id_product', $cr->id_product)
|
|
|
+ ->fields('pif_en' , array('name', 'nature', 'description', 'technical', 'keywords'))//, 'usage' , 'keywords'
|
|
|
+ ->distinct()->execute();
|
|
|
|
|
|
+ foreach ($infos_en as $record)
|
|
|
+ $infos['en'] = $record;
|
|
|
+
|
|
|
+ $infos['en']->description .= "<br />technical : ".$infos['en']->technical; // . "<br />usage".$infos['en']->usage
|
|
|
+
|
|
|
+ $cr->title = $infos['fr']->name;
|
|
|
+ $cr->name = array($infos['en']->name, $infos['fr']->name);
|
|
|
+ $cr->description = array($infos['en']->description, $infos['fr']->description);
|
|
|
+ $cr->nature = array($infos['en']->nature, $infos['fr']->nature);
|
|
|
+ $cr->language = array('en', 'fr');
|
|
|
+
|
|
|
+ #record keywords on memo
|
|
|
+ $cr->memo .= ($cr->memo != '' ? "\n\n" : '') . $infos['fr']->keywords;
|
|
|
+
|
|
|
|
|
|
- //
|
|
|
- // $cr->name = array($cr->name_en, $cr->name_fr);
|
|
|
- // $cr->description = array($cr->description_en, $cr->description_fr);
|
|
|
- // $cr->nature = array($cr->nature_en, $cr->nature_fr);
|
|
|
- // $cr->language = array('en', 'fr');
|
|
|
|
|
|
# parse companies
|
|
|
- dsm($cr->list_industrial, '-- $cr->list_industrial');
|
|
|
- dsm($cr->list_quarity, '$cr->list_quarity');
|
|
|
+ // dsm($cr->list_industrial, '-- $cr->list_industrial');
|
|
|
+ // dsm($cr->list_quarity, '$cr->list_quarity');
|
|
|
$industrials = explode(',', $cr->list_industrial);
|
|
|
$quarities = explode(',', $cr->list_quarity);
|
|
|
|
|
@@ -164,7 +144,7 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
->distinct()->execute();
|
|
|
|
|
|
foreach ($result as $record) {
|
|
|
- dsm($record);
|
|
|
+ // dsm($record);
|
|
|
$company = trim($record->company);
|
|
|
|
|
|
if($quarities[$i] == 'M'){
|
|
@@ -185,6 +165,10 @@ class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public function prepare($node, stdClass $row) {
|
|
|
// dsm('-- prepare --');
|
|
|
// dsm($node, '$node');
|