How do I access the values of my results from a view I have a preprocess function that I would like to run against a view, but I can not seem to be able to access the actual results. I have a custom entity called entity1 with two fields, field1 and field2. This function runs, but the value of $value is never set

function template_preprocess_views_view_hook(&amp;$variables) {
  // View options set by user.

  foreach ($variables['view']-&gt;result as $id =&gt; $result) {
    //Things I've tried:
    $value1 = $result-&gt;field_field_field1;
    $value2 = $result-&gt;field_field_field1[0]['raw']['value'];
    $value3 = $result-&gt;entity1_field_field1;
    $value4 = $result-&gt;field1;
    //and many other things
  }
}


The foreach loop does in fact cycle through for the correct number of results.
You need the method getValue() from each field to get the field data from row:

$view = $variables['view'];
$values = [];
foreach ($view-&gt;result as $row_id =&gt; $row) {
  foreach ($view-&gt;field as $field_id =&gt; $field ) {
    $values[$row_id][$field_id] = $field-&gt;getValue($row);
  }
}


If you want the rendered field use $field-&gt;render($row)