How to get the full product image URL in Magento

How to get the full URL of the product image in magento , I need to transfer the data from magento to django , so I need to get the full URL of the product in order to transfer the site

here is my code

<?php @ob_start(); @session_start(); ini_set('display_errors', 1); //for order update include '../../../../app/Mage.php'; Mage::app('default'); echo '<pre>'; if(isset($_REQUEST['productid'])){ $productId = $_REQUEST['productid']; }else{ echo 'Default Product => '; $productId = '12402'; // product ID 10 is an actual product, and used here for a test } $product = Mage::getModel('catalog/product')->load($productId); //load the product print_r($product->getthumbnail());<br/> print_r($product->getcreated_at()); ?> 
+7
source share
4 answers

You can try under the code above all, calling a directory helper

 echo Mage::helper('catalog/image')->init($product, 'thumbnail'); 

From this code, you can also get the caching path.

+22
source

After loading the product using the load () function, you can use the following in your code:

 $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage(); $imageCacheUrl = Mage::helper('catalog/image')->init($product, 'image')->resize(135,135); 

If you need a different cache size, use different numbers for the resize method.

+15
source

try it

 $product = Mage::getModel('catalog/product')->load($product_id); $full_path_url = Mage::helper('catalog/image')->init($product, 'thumbnail'); 
+6
source
  <img src="<?php echo Mage::helper('catalog/image')->init($_products, 'small_image')->resize(200,200);?>" width="200" alt=""> <?php ini_set('display_errors','on'); require_once 'app/Mage.php'; Mage::app('default'); $_products = Mage::getResourceModel('catalog/product_collection')->toOptionArray(); $product_id = $this->getRequest()->getParam('id'); $_products=Mage::getModel('catalog/product')->load($product_id);?> 
0
source

All Articles