Magento 1.9 : 获取产品图片 Get Image Gallery in list.phtml

$_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

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.