I have made a migration module to import the full content from a legacy Drupal 6 site to my new Drupal 7 site, using the migrate d2d module. Everything works fine, but I have just discovered that there are many custom meta tags added manually for both nodes and taxonomy in the legacy site (using the Metatags module). The taxonomy meta tags I can deal with manually, but I really would need to figure out how to add the mapping for metatags in my node migration classes. Do I add code in my general migration class in node.inc (that extends DrupalNode6Migration)?

Do I use prepareRow() to fetch info from the database and add this to a mapping with a default value in the new site? As far as I can see there are no fields in the legacy site that holds the metatags (I need title, keywords and description).

If anyone knows how to do this, please help.

1 Answer 1


Finally I came up with a solution and I post it here in case anyone else has the same problem. There are two tables in the legacy site named metatags and metapages, in which you can find everything needed for importing the metatags.

So in my prepareRow() in each node migration class I added these rows, and now the metatags from the legacy Drual 6 site has been imported to my Drupal 7 site :-)

$metapages_path = !empty($row->nid) ? 'node/'.$row->nid : false;
    $meta_title_pid = Database::getConnection($target='default', $key='legacy')->query('SELECT f.title, f.pid FROM {metapages} f WHERE f.path = :path',array(':path' => $metapages_path))->fetchAssoc();
$meta_title = !empty($meta_title_pid['title']) ? $meta_title_pid['title'] . ' | [site:name]' : '';
$meta_pid = !empty($meta_title_pid['pid']) ? $meta_title_pid['pid'] : false;
    $meta_keywords = Database::getConnection($target='default', $key='legacy')->query('SELECT f.value FROM {metatags} f WHERE f.name = :key AND f.parent_pid = :pid',array(':pid' => $meta_pid, 'key' => 'keywords'))->fetchAssoc();
    $meta_description = Database::getConnection($target='default', $key='legacy')->query('SELECT f.value FROM {metatags} f WHERE f.name = :key AND f.parent_pid = :pid',array(':pid' => $meta_pid, 'key' => 'description'))->fetchAssoc();      
$keywords = !empty($meta_keywords['value']) ? $meta_keywords['value'] : '';
$description = !empty($meta_description['value']) ? $meta_description['value'] : '';

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.