Render field with custom formatter on attribute change
The normal way to render a commerce field would be to use this:
Now I need to render it with a different formatter than the default and from what I know I need to use the field_view_field way to do that?
So far I have manage to render it with this:
$display = array('type' => 'custom_formatters_my_formatter'); // Formatter
$product_id = $node->field_product['und']['product_id']; // Product ID
$product = commerce_product_load($product_id); // Load the product
$output = field_view_field('commerce_product', $product, 'field_my_image', $display);
This works nice except I don't know how to get the current ID (  ) from the product that is currently beeing viewed.
Anyone have any suggestion how to solve this?
Kind regards, Mats