我只有一个MySQL表,每一行都有混合的英语/法语内容。我试图弄清楚如何将其迁移到正确的i18n配置的Drupal站点中。
我可以让Migrate将内容导入一种语言,但是我希望将其导入两种语言。有901行,因此它最终应创建1802个链接的节点。
我只是不知道如何设置Migrate模块以两次循环并链接节点。
编辑:我用这个并且能够合并两个:
public function postImport() {
parent::postImport();
// $ii should really be determined by $count_query
$ii = 2000;
for ($i = 1; $i < $ii; $i++) {
// Confirm SQL in phpMyAdmin to verify
$query = "SELECT n.nid, tid.field_bv_transfer_id_value
FROM {field_revision_field_bv_transfer_id} tid
INNER JOIN node n ON tid.entity_id = n.nid
WHERE tid.field_bv_transfer_id_value = $i;";
$result = db_query($query);
// Reset for each import
$currentRowCount = $current_translateid = 0;
foreach ($result as $record) {
if ($currentRowCount % 2 == 0) {
$node = node_load($record->nid);
$node->pathauto_perform_alias = FALSE;
$node->tnid = $record->nid;
$current_translateid = $record->nid;
node_save($node);
} else {
$node = node_load($record->nid);
$node->pathauto_perform_alias = FALSE;
$node->tnid = $current_translateid;
node_save($node);
}
$currentRowCount++;
}
}
}