0

I am migrating my Drupal 6 site to Drupal 7. I have vocabulary/category links like http://www.megaleecher.net/category/12.

How do I replicate this with Drupal 7? I exported the below view to Drupal 7, but it does not work.

$view = new view;
$view->name = 'vocabulary';
$view->description = '';
$view->tag = '';
$view->base_table = 'node';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'time';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Sort criterion: Node: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Argument: Taxonomy: Vocabulary ID */
$handler->display->display_options['arguments']['vid']['id'] = 'vid';
$handler->display->display_options['arguments']['vid']['table'] = 'vocabulary';
$handler->display->display_options['arguments']['vid']['field'] = 'vid';
$handler->display->display_options['arguments']['vid']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['vid']['default_argument_type'] = 'fixed';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['defaults']['query'] = FALSE;
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['path'] = 'category/%';
1
  • OK, it seems while the d2d migrate module imported the taxonomy and nodes it did not configure/imported/created the term-node relationship. Any ideas how to do ? Aug 12, 2013 at 10:41

2 Answers 2

0

check this migrate and migrate_extras module, it is very handy framework to migrate content, you can easily migrate

  • node
  • taxonomy/categories
  • users

Edited:

Let me clarify with your scenario, while migrating from source(D6) to destination(D7),

you have to define source field and destination fields as shown in below code sample.

first you have to migrate Taxonomy terms from D6 to D7. later on you have to migrate node entity, while preparing node migrate class, you have to migrate term reference field as it is. so that in prepareRow function we can replace with old term_id with new term_id which is already migrated.

For example see sample code.

abstract class JiveBlogMigration extends Migration {

public function __construct() {
// Always call the parent constructor first for basic setup
parent::__construct();

// With migrate_ui enabled, migration pages will indicate people involved in
// the particular migration, with their role and contact info. We default the
// list in the shared class; it can be overridden for specific migrations.

  }

}

/**
 * 
 * Jive Blog Post Information Migration class.
 * 
 */
class JiveBlogPostMigration extends JiveBlogMigration {

  public function __construct() {
  // The basic setup is similar to BeerTermMigraiton
  parent::__construct();
  $this->description = t('Jive Blog Post Data Migration.');
  $this->map = new MigrateSQLMap($this->machineName,
                array('jive_blog_post_id' => array(
                        'type' => 'int',
                        'not null' => TRUE,
                        'description' => 'Jive Blog Post ID.'
                    )
                ),
                MigrateDestinationNode::getKeySchema()
   );


// Added ContainerType field for mapping   
$query = db_select('migrate_jive_blog_post', 'mjbp')
        ->fields('mjbp', array('jive_blog_post_id', 'jive_user_id', 'jive_group_id', 'jive_container_type', 'subject', 'body', 'permalink', 'minorEdit', 'creationDate', 'modificationDate', 'status', 'displayName', 'blogstatus', 'feedEnabled', 'feedFullContent', 'pingOverride', 'pingServices', 'trackbacksEnabled', 'trackbacksModeration', 'trackbacksNotification')); //SELECT the fields from node
//generate the count for the number of records to be imported
$count_query = db_select('migrate_jive_blog_post', 'b');
$count_query->addExpression('COUNT(jive_blog_post_id)', 'cnt');
$source_fields = array(
    'jive_blog_post_id' => t('The id of a particular document in the jive system'),
    'term_data' => t("The taxonomy terms associated with the node"),
    'jive_container_id' => t("The social group or space id associated to the node decided in prepareRow()."),
);
$this->source = new MigrateSourceSQL($query, $source_fields, $count_query);

// Set up our destination - nodes of type blog
$this->destination = new MigrateDestinationNode('blog');

// Mapped fields
$this->addFieldMapping('title', 'subject')
        ->description(t('Mapping beer name in source to node title'));

// References to related objects (such as the author of the content) are
// most likely going to be identifiers from the source data, not Drupal
// identifiers (such as uids). You can use the mapping from the relevant
// migration to translate from the old ID to the Drupal identifier.
// Note that we also provide a default value of 1 - if the lookup fails to
// find a corresponding uid for the aid, the owner will be the administrative
// account.
$this->addFieldMapping('uid', 'jive_user_id')
        ->sourceMigration('JiveUserAccount')
        ->defaultValue(1);
// Mapping for Tags
$this->addFieldMapping('Tags', 'term_data');

// Additional mapping fields
$this->addFieldMapping('field_displayname', 'displayname');
$this->addFieldMapping('field_pingoverride', 'pingoverride');
$this->addFieldMapping('field_pingservices', 'pingservices');
$this->addFieldMapping('field_feedenabled', 'feedenabled');
$this->addFieldMapping('field_feedfullcontent', 'feedfullcontent');
$this->addFieldMapping('field_status', 'blogstatus');
$this->addFieldMapping('field_tbmoderation', 'trackbacksmoderation');
$this->addFieldMapping('field_tbnotification', 'trackbacksnotification');
$this->addFieldMapping('field_minoredit', 'minoredit');
$this->addFieldMapping('field_trackbacksenabled', 'trackbacksenabled');

//This is for path
$this->addFieldMapping('path', 'permalink');
$this->addFieldMapping('pathauto_perform_alias')
        ->defaultValue(0);


// Group mapping for space, personal, group associated Blog posts
$this->addFieldMapping('og_groups', 'jive_container_id');


$this->addFieldMapping('body', 'body');
$this->addFieldMapping('created', 'creationdate');
$this->addFieldMapping('changed', 'modificationdate');
$this->addFieldMapping('status', 'status');



// Unmapped destination fields
$this->addUnmigratedDestinations(array('revision_uid', 'teaser', 'revision', 'language', 'promote', 'sticky',
    'field_group_sticky', 'field_content_images', 'field_featured_content',));


//specify the unmapped source fields.
$this->addUnmigratedSources(array('jive_group_id', 'jive_container_type'));
}

public function prepareRow($current_row) {

 $source_id = $current_row->jive_blog_post_id;

 //populate all the tags associated with a particular node using the getDrupalTags() method
 //that returns an array of all the tags associated with a particular node.
 $term_data = JiveMigrationUtilities::getDrupalTags($source_id, 38); //38 is the object type for the blogpost in jive.
 if ($term_data) {
  $current_row->term_data = $term_data;
 }
 if ($current_row->jive_group_id != 'NULL') {
  $current_row->jive_container_id = JiveMigrationUtilities::getDrupalContainerNid($current_row->jive_container_type, $current_row->jive_group_id);
  }
 return TRUE;
}

}

Usual flow of migration module, it will create a mapping table for each migration class like migrate_map_jiveblogmigration, it contains sourceid1 and destid1 columns. for example D6 nid is as sourceid1 and D7 nid is as destid1.

in prepareRow function you can write a logic to replace old term_id with new term_id for each row of node migration.

5
  • I used migrate module to do the migration, thanks for introducing the migrate_extra module this seems will do the trick. Will update. Thanks Aug 10, 2013 at 3:06
  • I checked the module but already have migrated node, categories and users. I need to make them accessible by menu as described above ? Aug 10, 2013 at 3:18
  • if you have already migrated node, categories and users using migration framework. you can directly access those node/categories/user's as you normally do. let me know, if you are not clear. will try to help Aug 11, 2013 at 9:54
  • How it does not work - I tried mysite.gotpantheon.com/categories/internet but it does not work and says "page not found" Aug 11, 2013 at 10:00
  • and neither did the "category id" as in the original site. Aug 12, 2013 at 3:27
0

D2D module did not established the nid-term relationship when importing, so while we had the nodes and terms imported successfully there was no pointer relating the two which resulted in no results for category/vocabs.

Used Drush site-upgrade and things imported correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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