【问题标题】:Drupal 8 - Node reference migrate to entity reference typeDrupal 8 - 节点引用迁移到实体引用类型
【发布时间】:2019-11-27 19:59:41
【问题描述】:

我尝试按照以下步骤 https://www.drupal.org/docs/8/upgrade/upgrading-from-drupal-6-or-7-to-drupal-8 将 drupal 7 站点迁移到版本 8。但是,当迁移内容类型的字段时,我在引用其他内容类型的字段中出现这种类型的错误“尝试创建没有类型的 [field_name]。”。 “upgrade_d7_field”是我执行的迁移 id。我正在通过 drush 进行迁移。

我知道可能的问题,但我不知道如何解决。在 drupal 7 中,引用其他内容类型的字段类型是“节点引用”类型,但在版本 8 中,该类型不再存在,现在是“实体引用”类型。

我认为我应该更改迁移定义中的一些配置,但我不知道具体是什么。

这是迁移 id "upgrade_d7_field" 的迁移定义:

uuid: 2edaccb2-22a6-4482-895f-439bbbc66f1a
langcode: es
status: true
dependencies: {  }
id: upgrade_d7_field
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: alterFieldMigration
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
  - Configuration
migration_group: migrate_drupal_7
label: 'Field configuration'
source:
  plugin: d7_field
  constants:
    status: true
    langcode: und
process:
  entity_type:
    -
      plugin: get
      source: entity_type
  status:
    -
      plugin: get
      source: constants/status
  langcode:
    -
      plugin: get
      source: constants/langcode
  field_name:
    -
      plugin: get
      source: field_name
  type:
    -
      plugin: process_field
      source: type
      method: getFieldType
      map:
        d7_text:
          d7_text: d7_text
        taxonomy_term_reference:
          taxonomy_term_reference: taxonomy_term_reference
        image:
          image: image
        link_field:
          link_field: link_field
        file:
          file: file
        datetime:
          datetime: datetime
        list:
          list: list
  cardinality:
    -
      plugin: get
      source: cardinality
  settings:
    -
      plugin: d7_field_settings
destination:
  plugin: 'entity:field_storage_config'
migration_dependencies:
  required: {  }
  optional: {  }


我真的需要迁移 D7 网站的数据,它们有超过 17.000 条新闻,包括分类法、cmets 等等。

感谢您的帮助。提前致谢。

【问题讨论】:

    标签: drupal migration drupal-8 migrate


    【解决方案1】:

    您似乎正在使用 References 模块,该模块提供旧 CCK 包中的 node_referenceuser_reference 字段类型的 D7 版本。

    这个模块是在 drupal 7 早期启用这些字段类型的解决方案。

    一段时间后,Entity Reference 出现在 d7 中,它提供了一个通用字段类型来引用任意实体,并从那时起包含在 Drupal 8 核心中。

    要解决您的问题,您应该首先将参考字段迁移到正确的字段类型entity_reference

    有一个名为 Reference to EntityReference Field Migration 的模块可以帮助您在迁移 drupal 8 之前完成工作。

    【讨论】:

    • 谢谢。我要试试。您认为这也有助于我迁移使用视频模块嵌入字段的视频类型的字段吗??。
    • 我认为您不需要为此提供实体引用(除非您有“视频”实体类型?)。视频模块有一个 d8 版本,所以我假设它支持迁移数据,也就是说项目页面明确提到“使用所见即所得模块将视频嵌入到节点主体仅 d7 ”。如果您担心显示嵌入式视频,您可以查看example 和 d8 版本中可用的字段小部件。
    • 我已经迁移了我需要的一切。非常感谢您的帮助。我很感激。
    【解决方案2】:

    假设 d7 字段位于名为 publications 的内容类型上,并且该字段是 field_articles_d7 引用名为 articles 的内容类型,新的 D8 实体引用字段称为 field_articles_d8(假设这是在名为publications的同一内容类型上)也引用名为articles的内容类型

    顺序应该是到

    • 迁移 article 内容类型(迁移 id:d7_node_article)
    • 然后迁移publications节点类型(迁移id:d7_node_publication)
      • 您需要在流程部分执行此操作
        •         field_articles_d8:
                      plugin: migration_lookup
                      migration: d7_node_article
                      source: field_articles_d7
          
          

    这通常是将 Drupal 7 中的节点引用迁移到 Drupal 8 中的实体引用的顺序过程

    【讨论】:

      猜你喜欢
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多