Skip to main content
added 268 characters in body
Source Link
adal
  • 404
  • 3
  • 7

Load the field collection using entity_load by passing the entity id. It gives you object where you can get the Host entity of the loaded entity. example profile2 will have user entity as host entity, or commerce line item will have commerce order as host entity.

$entity = entity_load('field_collection_item', $your_file_collection_id);
$host_entity = $entity->hostEntity();
echo $host_entity->nid;
$entity = entity_load('field_collection_item', $your_file_collection_id);
$host_entity = $entity->hostEntity();
echo $host_entity->nid;

Load the field collection using entity_load by passing the entity id. It gives you object where you can get the Host entity of the loaded entity. example profile2 will have user entity as host entity, or commerce line item will have commerce order as host entity.

$entity = entity_load('field_collection_item', $your_file_collection_id);
$host_entity = $entity->hostEntity();
echo $host_entity->nid;
Source Link
adal
  • 404
  • 3
  • 7

$entity = entity_load('field_collection_item', $your_file_collection_id);
$host_entity = $entity->hostEntity();
echo $host_entity->nid;