Hi

My migrations test are on the go but actually my imported nodes doesn't keep their tags (terms) and i need to set them again.
I found a way to keep the author of imported nodes like this in my migration class :

public function __construct(array $arguments) {
    parent::__construct($arguments);
    
    //On défini la source et la cible depuis les infos de base
      $this->source = new MigrateSourceSQL($this->query(),
      $this->sourceFields,NULL, $this->sourceOptions);
....
   //La taxonomie via champs custom
   $this->addFieldMapping('taxonomy_vocabulary_2', '2');
   $this->addFieldMapping('taxonomy_vocabulary_1', '1');
   //Correspondance des utilisateurs et des termes
   $this->addFieldMapping('uid', 'uid');   
   $this->addFieldMapping('tnid', 'tnid'); //doesn't work
      
}
but don't for terms..what is the way to keep my terms assigned to nodes ?

thanks
CommentFileSizeAuthor
#9 super term migration.zip3.4 KBsummit

Comments

aiphes’s picture

i think i found the fix but it bring me to ask :

actually

$this->addFieldMapping('taxonomy_vocabulary_1', '1');

could be

$this->addFieldMapping('field_taxo_vdl', '1');

so what happen to
taxonomy_vocabulary_1 because i get two similar term reference fields, only the taxonomy_vocabulary_1 is necessary .
the field_taxo_vdl field is convert from a content taxonomy field created into D6...than after the upgrade i get 2 similars fields..
could i delete one of them ? so keep only one mapping...
more generally is it better to transform the core taxonomy in D6, into content taxonomy fields before upgrading a website ?

thanks

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

In Drupal 7, term associations are done with explicit term reference fields, like 'field_taxo_vdl'. The 'taxonomy_vocabulary' stuff would have been how you specified the vocabularies related to the node in a migration to Drupal 6.

aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

ok, so can i keep the 2 mapping like this ?

$this->addFieldMapping('taxonomy_vocabulary_1', '1');
$this->addFieldMapping('field_taxo_vdl', '1');

the first to move vocabulary terms to the vocabulary_1 and the other to tag content.

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

If field_taxo_vdl is your term reference field corresponding to the vocabulary that had vid=1 in the source system, that's all you need. A pseudo-field of the 'taxonomy_vocabulary' form would only be used if you were migrating to Drupal 6 - if you're using migrate_d2d, then you're migrating to Drupal 7 and thus migrating into proper term reference fields. Go to the detail page for your migration in the UI - you should see 'field_taxo_vdl' there, but no 'taxonomy_vocabulary_1'.

aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

actually in the ui (admin/content/migrate/groups/BL_migration/D2D_BriseLamesNodes_ContentSortie) for source i get :

  • field_taxo_vdl,
  • 1
  • 2 ;

and in the destination :

  • taxonomy_vocabulary_2 Taxo-tri-fonctionnel (taxonomy_term_reference)
  • taxonomy_vocabulary_1 Type d'évènement (taxonomy_term_reference)
  • field_taxo_vdl Type d'évènement (taxonomy_term_reference)

more generally,do i need to use the prepareRow function ?

new test with functional code (d7-grawitz.vmdev) and the migration replace existing term by a stub one, rollback migration doesn't get back my previous term..:(
my code:


  $this->addFieldMapping('taxonomy_vocabulary_1', '1')
      ->sourceMigration('Tri_fonctionnel') // 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_6', '6')
            ->sourceMigration('Actualites') // 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'));
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

OK, since you do have real term reference fields with the taxonomy_vocabulary names, you should map them. Use sourceMigration() as you are to relate the incoming tids to the vocabulary migrations. However, the arguments() method is deprecated, don't use that, use subfield notation:

$this->addFieldMapping('taxonomy_vocabulary_1:source_type')
     ->defaultValue('tid');
aiphes’s picture

Status: Postponed (maintainer needs more info) » Fixed

Yes, i think i achieve this by changing the code like this :
this one create stub because it make reference of a migration already done when i upgraded the core.

$this->addFieldMapping('taxonomy_vocabulary_1', '1');
     ->sourceMigration('Tri_fonctionnel'); // 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.
      $this->addFieldMapping('taxonomy_vocabulary_1:source_type')
     ->defaultValue('tid');

So when i use this code, term is assigned to nodes as expected :

$this->addFieldMapping('taxonomy_vocabulary_1', '1');
      // This tells the migration to match on the term ID instead of the default, which is the term name.
      $this->addFieldMapping('taxonomy_vocabulary_1:source_type')
     ->defaultValue('tid');

but i get strange thing : the body content is display but when i go on edit mode, the field is empty..i'm using wysiwyg and CKE as editor.perhaps need another question ?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

summit’s picture

Issue summary: View changes
StatusFileSize
new3.4 KB

Hi,
On this page http://btmash.com/article/2012-02-16/migrate-more-less-or-how-i-learned-...
I found a term reference sort of module. I have in winzip set what I made of it.
Question one: How can I get connection without being dependent of Commerce_Migrate_Ubercart
question two: Will this module work and how can I trigger it then within Migrate D-D?

Hopefully this is the right place to bring this submodule in and are there people out there how can make this a Migrate D-D- add on to get nodes with reference to terms in.
Otherwise, does someone have a module, in winzip which does this already?

Greetings, Martijn