I can get the entity reference field node id from my field collection like this:
function mymodule_node_update($node){
if ($node->type == 'article'){
$node_wrapper = entity_metadata_wrapper('node', $node);
$before = array();
foreach ($node_wrapper->field_collection_ingredients->value() as $key => $field_collection_wrapper) {
$before[$key] = $field_collection_wrapper->field_ingredient[LANGUAGE_NONE][0]['target_id'];
}
}
Doing:
$before[$key] = $field_collection_wrapper->original->field_ingredient[LANGUAGE_NONE][0]['target_id'];
Causes an error.
Basically I have an entity reference, which allows unlimited values, inside the the field collection.
When someone removes a value from the entity reference field, I need to know which value was removed as I need the Node ID to update that node that was removed from the entity reference.
field_collection_ingredients
field value for$node->field_collection_ingredients[LANGUAGE_NONE]
and$node->original->field_collection_ingredients[LANGUAGE_NONE]
, this will give exactly which field collection was removed, you can then try loading that field collection and then load$fc->field_ingredient[LANGUAGE_NONE][0]['target_id'];
field value to update Node referenced infield_ingredient
field.