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.
Comments
Comment #1
danielb commentedAccording 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.
Comment #2
danielb commentedThe 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.
Comment #3
danielb commentedI'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.
Comment #4
skwashd commentedOne 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.
Comment #5
danielb commentedI can tell if a node is D6 or D7, the question is... how to convert it?
Comment #6
safetypinAre 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 31I haven't started digging too deep, but I'd like to see if I can do anything to help get this running.
Comment #7
clashar commenteddo 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
Comment #8
safetypinI'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.
Comment #9
thumb commentedThanks idlewilder, an initial test of importing via text field after applying your patch worked nicely for me.
Comment #10
thumb commentedUpdate: 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.
Comment #11
danielb commentedMarked #1135392: Fatal error during import as duplicate
Comment #12
danielb commentedI've added idlewilder's patch in #8
Comment #13
danielb commentedComment #14
danielb commentedI'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.
Comment #15
danielb commentedPostponed 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.
Comment #16
danielb commentedI am removing this module, it gives false hope. Advanced importing shall now be done through the Feeds module.