0

So im migrating comments from a different database to Drupal 7 but i cant understand why this wont work. Im successful with migrating nodes, i only mapped the node fields and somehow its node_revision seemed to have automatically updated too.

But in comments it doesnt work, i know to add a comment these tables are affected in drupal:

  1. comment
  2. field_data_comment_body
  3. field_revision_comment_body

am i missing some mapping here in my code?

$this->addFieldMapping('cid', 'id');
    $this->addFieldMapping('is_new')->defaultValue(TRUE); // i dont know what this thing does


    $this->addFieldMapping('nid', 'mainthread');
    $this->addFieldMapping('pid', 'parent')
         ->sourceMigration('ForumComment')
         ->description('Parent comment.');
    $this->addFieldMapping('comment_body', 'body');
    $this->addFieldMapping('subject', 'subject');
    $this->addFieldMapping('hostname', 'host');
    $this->addFieldMapping('created', 'date');
    $this->addFieldMapping('changed', 'last');
    $this->addFieldMapping('name', 'author');
    $this->addFieldMapping('status')
         ->defaultValue(COMMENT_PUBLISHED);
    $this->addFieldMapping('comment_body:format')
        ->defaultValue('full_html');

    /*$this->addFieldMapping('uid', 'accountid')
         ->sourceMigration('WineUser')
         ->defaultValue(1); */


    //optional
    //$this->addFieldMapping('tid', 'category_id');
    //$this->addFieldMapping('comment_count', 'hits');

    // Unmapped destination fields
    $this->addUnmigratedDestinations(array('uid', 'thread', 'mail', 'homepage', 'language', 'comment_body:language'));

      $this->addUnmigratedSources(array('category_id'));

and is my destination correct? here it is:

$this->destination = new MigrateDestinationComment('comment');

based on my code only the comment table is mapped, i just assumed that the body and its revision will automatically map too like in my migration of nodes.

Help please

1

I got it, you need to add another class for the mapping of the body of the comment

and the destination should be 'comment_node_forum'

1
0

You have to follow a format here:

so instead of

$this->destination = new MigrateDestinationComment('comment');

It should be

$this->destination = new MigrateDestinationComment('comment_node_article');

Where comment_node_'nodetype' is a format and above the node type that I have used is "article".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.