Closed (fixed)
Project:
Field collection
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 May 2016 at 17:35 UTC
Updated:
17 Jun 2016 at 12:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
caxy4 commentedThe patch below implements a MigrateDestinationInterface class to set the host entity of an incoming field_collection_item.
This allows basic migrations of field_collection_items to work provided two required destination properties exist:
I chose the name of the host_type destination property to be in-line with the field_collection_item table schema.
Comment #3
jmuzz commentedThanks @caxy4.
I'm interested in this approach of importing the field collection item entities and letting the fields in the host get set by saving the field collection item. It seems like an effective way to bypass the problems with migrating the fields directly.
I tried applying the patch and clearing my cache. I'm not seeing anything different at /upgrade on my test site though.
I'd like to delve into this more deeply. Maybe you can explain what I am missing? I expected field_collection_item to show there along with node etc.
I also tried running the migration but the data doesn't seem to transfer over correctly.
Comment #4
jmuzz commentedComment #5
caxy4 commentedUploading a slightly modified patch that I meant to upload initially.
Two differences: name of host_type destination property changed from "host_entity_type" to "host_type" and returning an array instead of an int.
Comment #6
caxy4 commented@jmuzz with respect to your question about not seeing anything different at /upgrade:
I wouldn't expect you'd see anything different. This patch only exposes a migration destination plugin a migration could make use of; I haven't added a migrate path from D7.
The use case I developed the approach to solve is migrating CSV data, which, with the help of migrate_tools, migrate_plus, and migrate_source_csv, can be done by registering a migration with a YAML file (see Using the Migrate Source CSV plugin).
The only constraints imposed by my patch is that your YAML file must define "host_type" and "host_entity_id" via it's process plugin and use the destination plugin the patch defines:
Comment #9
jmuzz commentedThanks @caxy4.
I wonder if there is a plugin in core it could be tested with.
If not, tests will need to be added when there is a way to migrate field collections from Drupal 7.
Comment #10
killes@www.drop.org commentedThanks for providing this!
I am trying to use this using this setup:
however I get
Missing bundle for entity type field_collection_item
Do I need to set field_name somewhere?
Comment #11
killes@www.drop.org commentedThis worked for me:
Comment #12
killes@www.drop.org commentedHmm, when I try to update I get:
throw new \Exception(t('The host entity may be set only during creation of a field collection item.'));
this is from
public function setHostEntity($entity, $create_link = TRUE) {
in
field_collection/src/Entity/FieldCollectionItem.php
Not sure why this is, the host entity setting could be ignored instead.
Comment #13
tjferre commentedgetting the following error when using drupal /upgrade,
Attempt to create a field field_xyz that does not exist on entity type field_collection_item.
Any ideas?
Comment #14
jmuzz commentedIf any of these questions are about upgrading from a previous version of Drupal, that part isn't done yet, but there is information about it here: #2715397: Migration path from Drupal 7.x