Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created September 2, 2024 12:01
Show Gist options
  • Save junaidpv/fd57224429f233f3a3324450fae85556 to your computer and use it in GitHub Desktop.
Save junaidpv/fd57224429f233f3a3324450fae85556 to your computer and use it in GitHub Desktop.
Nested migrated field_collection items are still having field_collection_item as parent type set. Fix it.
diff --git a/src/Plugin/migrate/source/d7/FieldCollectionItem.php b/src/Plugin/migrate/source/d7/FieldCollectionItem.php
index 0dc9460..f34fc2d 100644
--- a/src/Plugin/migrate/source/d7/FieldCollectionItem.php
+++ b/src/Plugin/migrate/source/d7/FieldCollectionItem.php
@@ -71,8 +71,12 @@ class FieldCollectionItem extends FieldableEntity {
])
->range(0, 1);
$parent_row = $query->execute()->fetchObject();
+ $parent_type = $parent_row->entity_type;
+ if ($parent_type == 'field_collection_item') {
+ $parent_type = 'paragraph';
+ }
$row->setSourceProperty('parent_id', $parent_row->entity_id);
- $row->setSourceProperty('parent_type', $parent_row->entity_type);
+ $row->setSourceProperty('parent_type', $parent_type);
}
// Get Field API field values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment