Render a Views table row ID using a field as the ID value I am trying to apply an ID to table rows in a view using a field as the ID value.

I've copied views-view-table.tpl.php template to my theme template folder and renamed it based on the view I am working with.

I'm using Commerce Kickstart2, and I would like to id the table rows in this view by the SKU of each product.

I added SKU as a field in my view and then render it as a class for the Views Row using replacement patterns for the row class of a table view. (See screen capture).



In my template this is the line that writes the row class:

&lt;tr &lt;?php if ($row_classes[$row_count]) { print 'class="' . implode(' ', $row_classes[$row_count]) .'"';  } ?&gt;&gt;


I would like to add to that the field SKU as a row ID: id="SKU Value Here".

I have tried a number of ways without success.

after running print_r($view->result); at the top of the template I get this:

Array ( [0] => stdClass Object ( [product_id] => 1 [commerce_product_sku] => sample1 [field_data_title_field_commerce_product_entity_type] => commerce_product [field_data_commerce_price_commerce_product_entity_type] => commerce_product [_field_data] => Array ( [product_id] => Array ( [entity_type] => commerce_product [entity] => stdClass Object ( [revision_id] => 1 [sku] => sample1 [title] => Product 1 [revision_uid] => 1 [status] => 1 [log] => [revision_timestamp] => 1423407240 [data] => [product_id] => 1 [type] => product [language] => und [uid] => 1 [created] => 1418869347 [changed] => 1423407240 [commerce_price] => Array ( [und] => Array ( [0] => Array ( [amount] => 1600 [currency_code] => USD [data] => Array ( [components] => Array ( ) ) ) ) ) [field_images] => Array ( [und] => Array ( [0] => Array ( [fid] => 1 [uid] => 1 [filename] => tote-1v1.jpg [uri] => public://tote-1v1.jpg [filemime] => image/jpeg [filesize] => 48075 [status] => 1 [timestamp] => 1418869347 [alt] => [title] => [width] => 860 [height] => 842 ) 1 => Array ( [fid] => 2 [uid] => 1 [filename] => tote-1v2.jpg [uri] => public://tote-1v2.jpg [filemime] => image/jpeg [filesize] => 52861 [status] => 1 [timestamp] => 1418869347 [alt] => [title] => [width] => 860 [height] => 1251 ) [2] => Array ( [fid] => 3 [uid] => 1 [filename] => tote-1v3.jpg [uri] => public://tote-1v3.jpg [filemime] => image/jpeg [filesize] => 96645 [status] => 1 [timestamp] => 1418869347 [alt] => [title] => [width] => 860 [height] => 1100 ) ) ) [title_field] => Array ( [und] => Array ( [0] => Array ( [value] => Product 1 [format] => [safe_value] => Product 1 ) ) ) [field_associated_product_diagram] => Array ( [und] => Array ( [0] => Array ( [tid] => 272 ) ) ) [title_original] => Product 1 ) ) ) [field_title_field] => Array ( [0] => Array ( [rendered] => 

If anyone can lend any insight into how to accomplish this, I would appreciate it.
Try this to add an id attribute with your SKU based on the $view->result output:

 &lt;tr &lt;?php if ($row_classes[$row_count]) { print 'class="' . implode(' ', $row_classes[$row_count]) .'"';  } ?&gt; id="&lt;?php print $view-&gt;result[0]-&gt;commerce_product_sku; ?&gt;"&gt;