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

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).'" />'

其他
使用以下代码来加载产品的缓存映像

Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135);
//or
Mage::helper('catalog/image')->init($_product, 'image')->resize(135);

使用集合

$collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('small_image') //or
        ->addAttributeToSelect('thumbnail')  //or
        ->addAttributeToSelect('image');

发表评论

发表评论

*

沙发空缺中,还不快抢~