$_product_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
foreach($_product_images->getItems() as $_product_image) echo $_product_image->getUrl();
// or
foreach($_product_images->getItems() as $_product_image)
echo '<img src="'.Mage::helper('catalog/image')->init($product, 'image', $_product_image->getFile())->resize(100, 100).'" />'
其他:
load product’s cached image using collection by following codes
Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135);
or
Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(135);
or
Mage::helper('catalog/image')->init($_product, 'image')->resize(135);
this is the collection which i used
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('small_image') //or
->addAttributeToSelect('thumbnail') //or
->addAttributeToSelect('image');
转自: Magento 1.9 : 获取产品图片 Get Image Gallery in list.phtml
本文详细介绍了在Magento1.9中通过代码获取产品图片的多种方式,包括加载产品缓存图片、使用助手类操作产品图片等。文章还提供了一个用于获取产品图片画廊的代码片段,并解释了如何通过产品集合来获取小图、缩略图或原始图片。
1912

被折叠的 条评论
为什么被折叠?



