Fatal error: Call to undefined function entity_view_mode_prepare() /sites/all/modules/field_collection/field_collection.entity.inc on line 600 I get this error as I was doing my work. How do I fix this fatal error?


  Fatal error: Call to undefined function entity_view_mode_prepare() in
  .sites/all/modules/field_collection/field_collection.entity.inc on
  line 600
This error has been removed in latest drupal 7 versions. Please upgrade your drupal core version to the latest.

OR
Temporary solution:
Copy and paste the below function in includes/common.inc file

function entity_view_mode_prepare($entity_type, $entities, $view_mode, $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']-&gt;language;
}

// To ensure hooks are never run after field_attach_prepare_view() only
// process items without the entity_view_prepared flag.
$entities_by_view_mode = array();
foreach ($entities as $id =&gt; $entity) {
$entity_view_mode = $view_mode;
if (empty($entity-&gt;entity_view_prepared)) {

  // Allow modules to change the view mode.
  $context = array(
    'entity_type' =&gt; $entity_type,
    'entity' =&gt; $entity,
    'langcode' =&gt; $langcode,
  );
drupal_alter('entity_view_mode', $entity_view_mode, $context);
}

$entities_by_view_mode[$entity_view_mode][$id] = $entity;
}

return $entities_by_view_mode;
}