Created
September 2, 2024 12:01
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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