如何解决Drupal 使用 entity_lookup
我正在从 XML 文件迁移到现有 Drupal 9 站点上的节点。其中一个字段是具有两级层次结构的现有分类法。该导入部分的 XML 示例如下所示:
<nrts>
<nrt>
<levelone>Fire</levelone>
<leveltwo>Prescribed fire</leveltwo>
</nrt>
<nrt>
<levelone>Natural Resource Management & Use</levelone>
<leveltwo></leveltwo>
</nrt>
<nrt>
<levelone>Natural Resource Management & Use</levelone>
<leveltwo>Economics</leveltwo>
</nrt>
</nrts>
我的迁移配置的相关部分如下所示(我使用 Migrate Process Vardump 插件提供调试输出):
field_nrt_1:
-
plugin: skip_on_empty
source: nrt
method: process
-
plugin: vardump
header: 'Before processing'
-
plugin: sub_process
process:
target_id:
plugin: entity_lookup
entity_type: taxonomy_term
bundle_key: vid
bundle: national_research_taxonomy
value_key: name
ignore_case: true
迁移进行时没有错误,并且当我运行 drush migrate-messages 时没有列出任何内容。这是输出的结尾,带有 vardump 插件提供的分类数组:
Before processing: array(2) {
["levelone"]=>
string(21) "Forest & Plant Health"
["leveltwo"]=>
string(16) "Invasive species"
}
Before processing: array(2) {
["levelone"]=>
string(33) "Inventory,Monitoring,& Analysis"
["leveltwo"]=>
string(0) ""
}
[notice] Processed 169 items (169 created,0 updated,0 failed,0 ignored) - done with 'ximport054'
当我检查新创建的节点时,其他所有内容都在那里,但 field_nrt_1 保持为空。我在迁移中还有其他单级分类法,所以我知道 entity_lookup 正在工作。我已经尝试了 xml 和 simple_xml 解析器并得到了相同的结果。显然我错过了一些小部分,但我不知道它是什么。
如果您能帮助我找到正确的方向,我将不胜感激。谢谢!
解决方法
我自己解决了问题。为了其他可能为此苦苦挣扎的人的利益,我将以下配置与 Migrate Hierarchical Taxonomy 插件和以下配置一起使用:
field_nrt_1:
-
plugin: skip_on_empty
source: nrt
method: process
-
plugin: vardump
header: 'Before processing'
-
plugin: sub_process
process:
target_id:
plugin: hierarchical_taxonomy
entity_type: taxonomy_term
bundle_key: vid
bundle: national_research_taxonomy
value_key: name
ignore_case: true
source:
- levelone
- leveltwo
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。