【问题标题】:Drupal 8.1.1 - Migrate 3400 INSERT (from sql) to custom content typeDrupal 8.1.1 - 将 3400 INSERT(从 sql)迁移到自定义内容类型
【发布时间】:2016-11-10 11:03:47
【问题描述】:

我需要将 3400 行从 phpMyAdmin 导出迁移到 Drupal 8 上的自定义内容类型。

我尝试使用迁移模块,但例如 Migrate Plus 和迁移工具与我的 Drupal (8.1.1) 版本不兼容

我想使用 PHP 脚本导入记录。

我已经尝试了很多东西,但在很多情况下我都说“未定义的函数”(例如,通过使用 entity_create)以及我做过的更多证据。

示例 1:

$new_page_values = array();
$new_page_values['type'] = 'my_content_type';
$new_page_values['title'] = "Titulo";
$new_page_values['path'] = "Path";

$new_page = entity_create('node', $new_page_values);
$new_page->save();

示例 2

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$node = \Drupal\node\Entity\Node::create(array(
          'type' => 'article',
          'title' => 'The title',
          'langcode' => $language,
          'uid' => 1,
          'status' => 1,
          'body' => array('The body text'),
          'field_date' => array("2000-01-30"),
            //'field_fields' => array('Custom values'), // Add your custon field values like this
    ));
$node->save();

示例 3:

db_insert('example_entity')
    ->fields(array(
      'type' => $entity->getEntityTypeId(),
      'id' => $entity->id(),
      'created' => REQUEST_TIME,
      'updated' => REQUEST_TIME,
    ))
    ->execute();

我正在尝试从服务器控制台运行一个 .php 文件 (php updateData.php)

感谢和问候。

【问题讨论】:

  • 请提供MCVE
  • 示例发布在问题上。

标签: php drupal entities migrate


【解决方案1】:

Javier,D8 中的迁移仍然是 WIP。

我的建议:

  • 安装最新的 Drupal 8.1,
  • migrate_toolsmigrate_plusmigrate_source_csvmigrate_source_json 安装最新的模块。最好是最新的测试版。
  • 将您的 phpAdmin 输出更改为 csv 文件。

也许您需要创建自定义实体。 Migrate_tools 有 2 个迁移示例。它还包含一个 csv 示例。迁移过程应该无缝地导入你的东西。

提示: YAML 文件对空格等语法极为敏感。而且您不必识别外部/迁移数据库。但请记住,昨天有效的方法,今天可能会有所不同。在过去的 6 个月里,我一直在进行迁移。

迁移过程与 D7 完全不同。

已编辑: 安装 Drush 8。使用 Composer 是一种简单的方法。从命令行运行迁移脚本需要 Drush,清单已过时。

编辑 2: IMO 对使用 D8 迁移以及为何使用 D8 迁移的最佳解释。 看看这个网站https://blog.liip.ch/archive/2016/05/04/using-the-new-drupal-8-migration-api-module.html。您希望使用自己的 PHP 似乎主要是因为您似乎无法使用 D8 的迁移?

【讨论】:

    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 2023-03-24
    • 1970-01-01
    • 2011-03-30
    相关资源
    最近更新 更多