Actually I can migrate nodes depending on their type, and the author comes with node import like this in d2d :
$this->addFieldMapping('uid', 'uid');
but I don't know how to do the same to keep terms attached to nodes..I believe that in Drupal6 source, terms are frequently assigned from the core system, not via the content taxonomy module that represent the Drupal7 way.
Do you think I can do that actually, or do I need to modify the source and adopt the content taxonomy way before migrating nodes or generally upgrading from Drupal 6 to Drupal 7 ?
Thanks
EDIT: my migration class code
class NodesPageInnovationsMigration extends DrupalNode6Migration {
/* ==============================================================================
* -- Pour limiter l'import aux nodes créés aprés la date indiquée --
*
* ==============================================================================
*/
//protected function query() {
// $query = parent::query();
// $query->condition('created', strtotime('28-03-2013'), '>');
// return $query;
// }
public function __construct(array $arguments) {
parent::__construct($arguments);
//Le nom machine de la migration de nodes associée comme dépendances
// $this->dependencies[] = 'D2D_RostandNodes_PageInnovations';
//On défini la source et la cible depuis les infos de base
$this->source = new MigrateSourceSQL($this->query(),
$this->sourceFields,NULL, $this->sourceOptions);
// We're replacing the legacy field_published, which was a text field, with a new date field
$this->addFieldMapping('field_publish_date', 'field_published');
//Préservation du NID des nodes importés
$this->addFieldMapping('field_legacy_nid', 'nid')
->description('We have a common field to save the D6 nid');
/* ==============================================================================
* -- Mappage de la taxonomie --
* Assigned terms are represented in Drupal 6 by their vid, migrate to the new term
* reference field, translating the tid from the legacy value.
* ==============================================================================
*/
//$this->addFieldMapping('field_NomduChampCible', 'VidSource')
//La taxonomie via champs custom ou du core (D6)
// The first param is for the D7 field name.
// The second param is for the old site's vocab ID.
$this->addFieldMapping('taxonomy_vocabulary_1', '1')
// ->sourceMigration('Tags') // This is the machine name of the tags migration.
// This tells the migration to match on the term ID instead of the default, which is the term name.
->arguments(array('source_type' => 'tid'));
$this->addFieldMapping('taxonomy_vocabulary_2', '2')
// ->sourceMigration('Tags') // This is the machine name of the tags migration.
// This tells the migration to match on the term ID instead of the default, which is the term name.
->arguments(array('source_type' => 'tid'));
//$this->addFieldMapping('field_taxo_vdl', 'field_taxo_vdl'); inutile car dans D7 taxo est un champ
/* ==============================================================================
* -- Mappage des champs custom CCK --
* $this->sourceFields['NomChampSource'] = t('DescriptionChampSource');
* ==============================================================================
*/
// $this->sourceFields['field_fichier_joint_lycee'] = t('Joindre un fichier');
// $this->sourceFields['field_lien_page_lycee'] = t('Liens utiles');
// $this->sourceFields['field_video_lycee'] = t('Ajout galerie Flickr');
$this->addFieldMapping('field_video_externe', 'field_video_externe');
$this->addFieldMapping('field_fichier_joint_innovation', 'field_fichier_joint_innovation');
$this->addFieldMapping('field_fiche_action_innovation', 'field_fiche_action_innovation');
$this->addFieldMapping('field_date_evenement', 'field_date_evenement');
//Les champs custom pour les contenus VDL
$this->addFieldMapping('field_illus_vdl', 'field_illus_vdl');
$this->addFieldMapping('field_video_vdl', 'field_video_vdl');
$this->addFieldMapping('field_galerie_image_vdl', 'field_galerie_image_vdl');
$this->addFieldMapping('field_choix_galerie_vdl', 'field_choix_galerie_vdl');
$this->addFieldMapping('field_liens_vdl', 'field_liens_vdl');
//Correspondance des utilisateurs
$this->addFieldMapping('uid', 'uid');
//$this->addFieldMapping('tnid', 'tnid'); traduction du terme
}
/* ==============================================================================
* -- Manipulation et mise en forme des données des champs mappés --
*
* ==============================================================================
*/
public function prepareRow($row) {
// Always include this snippet, in case our parent class decides to ignore the row
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
//ici le code pour formatter les data
}
}
drupal_write_record
to write the node object with the nid set, prior to save. i.edrupal_write_record('node', $node); drupal_write_record('node_revision', $node);node_save($node);
- this will preserve the nid