How to get product image URL from product page? I'm developing a module for Drupal Commerce - Drupal 7 and I need to get the product image URL from product page but I couldn't find a solution for this.

I'm successfully fetching the product name, title, url but not the its image URL which really bothers me as I am used to WooCommerce where there is a very simple way of getting the image URL.
I have found a quick fix for this issue.

$product = commerce_product_load($productId); // loads the product by id
$productImage = drupal_json_encode(file_create_url($product-&gt;field_images['und'][0]['uri'])); // gets the main image of the product if it has multiple images and formats the link properly