Getting product display info from product ID and building node object with only needed fields


So we make  query to get node ID from particular product ID

$query = new EntityFieldQuery;
        $query->entityCondition('entity_type', 'node', '=')
        ->propertyCondition('type', 'product_display')
        ->fieldCondition('field_product_reference', 'product_id', '1092', '=')
        ->range(0, 1);

If node is present, we do the array building

        if ($result = $query->execute()) {

$nodeview = $result['node'];

  // At first we need to get field's id. If you already know field id, you can ommit this step
  // Get all fields attached to a given node type
  $fields = field_info_instances('node', 'product_display');


// Put all field names you want to load
$field_names = array('title_field', 'body');

foreach ($field_names AS $field_name) {
  // Get id of body field
  $field_id = $fields[$field_name]['field_id'];

  // Attach a field of selected id only to get value for it
  field_attach_load('node', $nodeview, FIELD_LOAD_CURRENT, array('field_id' => $field_id));
}

 // Get values of our node field, we use RESET to set the array pointer to first element of array
  $output = field_get_items('node', reset($nodeview), 'title_field');
  $output = field_get_items('node', reset($nodeview), 'body');

}

and some additional data why to use this over node_load
http://btmash.com/article/2012-04-13/i-just-want-one-field-using-fielda…