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

gralda’s picture

I'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?

nessunluogo’s picture

I'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:

Warning: Invalid argument supplied for foreach() in node_export_file_field_import() (linea 1091 di /sites/all/modules/contrib/node_export/node_export.module).

I'm using latest versions of all modules. Tryed _dev and the patch above here.
Is there something I'm missing?

nessunluogo’s picture

With 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:

$language = ($node->language == '') ? LANGUAGE_NONE: $node->language;

and replaced with this one:

$language = LANGUAGE_NONE;

Import finally worked!
Hope this helps.

crobicha’s picture

I 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

crobicha’s picture

nessunluogo's change from above worked for me, so I made it into a patch

---

crobicha’s picture

Status: Active » Needs review

Following 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"

ajlow’s picture

A 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?

Kras’s picture

I'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:

; Specify the version of Drupal being used.
core = 7.x
; Specify the api version of Drush Make.
api = 2

;Field Collection Deploy » Issues Field collection values are not being imported
;https://www.drupal.org/node/2289413
;uncomment line below if you use modules/contrib folder
;projects[field_collection_deploy][subdir] = contrib
projects[field_collection_deploy][patch][2289413] = https://www.drupal.org/files/issues/field_collection_deploy-fc-values-not-exported_2289413_0.patch

nessunluogo’s picture

Status: Needs review » Reviewed & tested by the community

Maintainer, please make a new version including this patch!
The updater always notify me to upgrade and this is not fair ;)
Thanks!

BarisW’s picture

Thanks, please commit.