I was using the Node Export and Node Export: import interface to copy a node containing a field collection. Although the node was getting created on the destination site, its field collection values were not.
It seems that it should be hook_node_export_node_import_alter that is implemented rather than hook_node_export_after_import_alter.
I can submit a patch but before I forget how to fix it, here is the change:
<?php
function field_collection_deploy_node_export_node_import_alter(&$node, $original_node, $save) {
if (isset($original_node->field_collection_deploy)) {
field_collection_deploy_import_field_collection($node, $original_node->field_collection_deploy);
}
}
?>
instead of field_collection_deploy_node_export_after_import_alter().
Comments
Comment #1
gralda commentedI'm running into this problem as well and would like to implement the fix you outline, but as a new person to this I'm struggling to understand what I need to change. are you able to assist?
Comment #2
nessunluogo commentedI'm unable to make this work too.
I have a custom node type with two field_collection fields. Each one of this has two taxonomy term reference and a boolean checkbox. There's also a file field and a Workflow with many states applied to the content type.
In export files i can find the field_collection_deploy section where values seems to be correctly packed.
I try to import the node in the same site where I exported the node and I get this warning:
I'm using latest versions of all modules. Tryed _dev and the patch above here.
Is there something I'm missing?
Comment #3
nessunluogo commentedWith some deeper debug I found what wasn't working for me: language.
In field_collection_deploy_import_field_collection (around row 188 in 7.x-1.0-beta3+0-dev) it uses $node->language if set. In my case it was italian (it) but all other fields were language indipendent (und), so I commented out this:
and replaced with this one:
Import finally worked!
Hope this helps.
Comment #4
crobicha commentedI have run into this issue as well, here are the steps to reproduce:
Create / edit existing node in content tab
Add dummy values into node and save
Node_export tab - View XML and notice that field_test and field_collection_deploy->field_test values correspond correctly
Copy exported xml into notepad
On site, Edit node->Delete->Confirm
Content-> Add content -> paste code from notepad -> Submit
Notice that values are not displayed in field_test xml
Comment #5
crobicha commentednessunluogo's change from above worked for me, so I made it into a patch
---
Comment #6
crobicha commentedFollowing this guide on how to contribute this patch: http://www.phase2technology.com/blog/how-and-why-to-patch-a-drupal-module/, final step is to change status to "Needs review"
Comment #7
ajlow commentedA combination of @xenophyle's and @nessunluogo's changes worked for me.
The only issue I now have are my image fields in the field collection are not being imported even though I can see the field being exported... Would anyone know how to ensure image fields are copied over?
Comment #8
Kras commentedI've adapted the patch file from crobicha (removed /sites/all/modules/field_collection_deploy from the references) so you can use it with this make script:
Comment #9
nessunluogo commentedMaintainer, please make a new version including this patch!
The updater always notify me to upgrade and this is not fair ;)
Thanks!
Comment #10
BarisW commentedThanks, please commit.