d8 preprocess commerce product entity
You can use hook_preprocess_commerce_product like so:

function mymodule_preprocess_commerce_product(&amp;$variables) {
  $product = $variables['elements']['#commerce_product'];
  ...
}