If this is a file out of the magento core api you must include this at the top

require_once './app/Mage.php';
Mage::app('default');
$_helper = Mage::helper('catalog/output');

since we are finding the product with id rather than using the this it is frequent to use the above in the file

Getting the product id with get method

$_productId = $_GET["id"];; // product ID 10 is an actual product, and used here for a test
Create the product object with the identified id

$_product = Mage::getModel(‘catalog/product’)->load($_productId); //load the product
optionally you could get sku even for testing purpose if youd like

echo $_product->getSku();//get anything you want using the typical syntax

getting GAllery of product object rray

$galleryData = $_product->getData('media_gallery');

and the final step is which all php developer must know about for each loop to get out ech object from an object array and showing the each object image URL

<?php foreach ($_product->getMediaGalleryImages() as $_image): ?>
<div> <img style="margin-bottom:30px;" src="<?php echo (string)Mage::helper('catalog/image')->init($_product, 'image', $_image->getFile()); ?>" width="1366" height="728" />
<?php endforeach; ?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.