62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* MaterioMateriauNodeMigration
|
|
*
|
|
*/
|
|
class MaterioMateriauNodeMigration extends MaterioBasicMigration {
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->description = t('Migrate Materio Materiau nodes');
|
|
|
|
// provide better description for source fields
|
|
// and add new field source not from sql
|
|
$source_fields = array(
|
|
'id_product' => t('Materiau id from source')
|
|
);
|
|
|
|
$query = db_select(MIG_MAT_SRC_DB .'.product_id', 'prod_id');
|
|
// WARNING ! product_info is double langauge + duplicate -> 4 rows each product
|
|
$query->join(MIG_MAT_SRC_DB .'.product_info', 'prod_info', 'prod_id.id_product = prod_info.id_product');
|
|
|
|
$query
|
|
->fields('pod_id', array('id_product', 'id_materio', 'status', 'temp_flag', 'sample_status', 'memo', 'source', 'date_creation', 'date_modif'))
|
|
->fields('prod_info', array('name', 'nature', 'description', 'usage', 'technical', 'keywords'))
|
|
->orderBy('id_product', 'DESC');
|
|
|
|
$query->groupBy('prod_id.id_product');
|
|
|
|
$this->source = new MigrateSourceSQL($query, $source_fields);
|
|
$this->destination = new MigrateDestinationNode('materiau');
|
|
|
|
$this->map = new MigrateSQLMap($this->machineName,
|
|
array(
|
|
'id_product' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'description' => 'OLD Unique Materiau ID',
|
|
'alias' => 'prod_id',
|
|
)
|
|
),
|
|
MigrateDestinationNode::getKeySchema()
|
|
);
|
|
|
|
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
|
$this->addFieldMapping('created', 'date_creation');
|
|
$this->addFieldMapping('changed', 'date_modif');
|
|
$this->addFieldMapping('status')->defaultValue(1);
|
|
$this->addFieldMapping('promote')->defaultValue(0);
|
|
$this->addFieldMapping('sticky')->defaultValue(0);
|
|
|
|
|
|
$this->addFieldMapping('title', 'name');
|
|
$this->addFieldMapping('field_memo', 'memo');
|
|
|
|
/*
|
|
TODO translate node
|
|
*/
|
|
//$this->addFieldMapping('language');
|
|
//$this->addFieldMapping('field_nature_titre', 'nature');
|
|
|
|
}
|
|
} |