I guess in Drupal 7 we can assume anything with strings for $node->body, or $node->teaser, or $node->format is a Drupal 6 style node.

<?php

  $node = (object) array(
    'nid' => $original_node->nid, 
    'vid' => $original_node->vid, 
    'type' => $original_node->type,
  );

  $langcode = empty($original_node->language) ? LANGUAGE_NONE : $original_node->language;

  if (!empty($original_node->teaser) && $original_node->teaser != text_summary($original_node->body)) {
    $node->body[$langcode][0]['summary'] = $original_node->teaser;
  }

  // Do this after text_summary() above.
  $break = '<!--break-->';
  if (substr($original_node->body, 0, strlen($break)) == $break) {
    $original_node->body = substr($original_node->body, strlen($break));
  }
  $node->body[$langcode][0]['value'] = $original_node->body;

  if (empty($original_node->body) && empty($original_node->format)) {
    $node->body[$langcode][0]['format'] = NULL;
  }
  elseif (!in_array($original_node->format, $sandbox['existing_text_formats'])) {
    $node->body[$langcode][0]['format'] = variable_get('filter_default_format', 1);
  }
  else {
    $node->body[$langcode][0]['format'] = $original_node->format;
  }

  _update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'body', $node->body);
?>

Code from http://api.drupal.org/api/drupal/modules--node--node.install/function/no...

This doesn't take into account other fields and information in contrib modules though.

So we might need to get clues from another module, like CCK to cover a lot of other cases, and perhaps just use node_save() instead of that storage write function.

CommentFileSizeAuthor
#8 994376-8.patch1.44 KBsafetypin

Comments

danielb’s picture

According to this there will be a content_migrate module #366364: [meta] Data migration from D6 contrib CCK fields to D7 Field API

Starting to think perhaps importing from D6 should be a separate module.

danielb’s picture

The other thing to consider is taxonomy. I was unable to get a clear idea of the changes from reading the taxonomy_update_* functions, I think I will just compare the output of taxonomies between drupal versions.

danielb’s picture

Status: Active » Postponed (maintainer needs more info)

I've added that code that updates the body field. But I have no idea how to go about handling CCK and Taxonomy fields. If anyone knows how, please contribute.

skwashd’s picture

One possibility is to define an export version in the generated export. If no version is specified, assume it is D6, if it exists then check the module can handle it.

danielb’s picture

I can tell if a node is D6 or D7, the question is... how to convert it?

safetypin’s picture

Are you still at a standstill at this point? I just attempted an import of some d6 nodes into d7, and got the following error.

PHP Fatal error: Cannot use string offset as an array in /xxx.xxx/sites/all/modules/contrib-stable/node_export/modules/node_export_d6_migrate/node_export_d6_migrate.module on line 31

I haven't started digging too deep, but I'd like to see if I can do anything to help get this running.

clashar’s picture

do I understand correctly, that using "Node export " it's not yet possible to export nodes from D6 and then import them into D7? I am interested in simple content type + panels

safetypin’s picture

StatusFileSize
new1.44 KB

I'm in the process of trying to figure this out. I have successfully imported basic node info, but am at the same sort of "roadblock" that Daniel mentions: converting Drupal 6 taxonomy to Drupal 7 fields.

I'm pretty new to coding for drupal, so I'm not sure I'm doing this correctly, but I'm attaching a patch to the node_export_d6_migrate.module code to import node body and input format. It looked to me like the $node->body part of the d6 was incompatible with the code from the 7006() update, but after making it an array, and putting in the langcode array, everything seems to be working to bring over the node body/summary.

thumb’s picture

Thanks idlewilder, an initial test of importing via text field after applying your patch worked nicely for me.

thumb’s picture

Update: After looking over my migration results with idlewilder's patch, I did have one minor issue, and one more significant issue.

My exported D6 nodes used a non-standard input format and the node code's format value for my D6 export was an integer. After changing the integer to a string value, 'full_html', the imported input format was set successfully during D7 import.

What isn't working is the import of the D6 nodes' path values (url alias), despite unchecking the imported node type's 'URL path' checkbox under 'Reset values on import'.

Anyone else having this problem?

Opened http://drupal.org/node/1100926 to report this issue.

danielb’s picture

danielb’s picture

I've added idlewilder's patch in #8

danielb’s picture

Status: Postponed (maintainer needs more info) » Active
danielb’s picture

I'm thinking if I build this: #1268956: Outstanding tasks feature
Then we can make the user pick the fields and new taxonomy term values manually.

danielb’s picture

Status: Active » Postponed

Postponed on #1285854: Integrate with Feeds module

If that issue is solved, then the d6_migrate stuff in node_export can be happily removed, as this technique could be a complete solution to migration.

danielb’s picture

Status: Postponed » Closed (won't fix)

I am removing this module, it gives false hope. Advanced importing shall now be done through the Feeds module.