获取图像产品

时间:2013-11-12 12:31:52

标签: magento

我需要获得一种产品的所有图像。

我试过这个:

<?php $_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages(); ?>

并且他在变量$ _images中给出了图像,但我不知道如何访问这个变量。

当我看到变量时:

Varien_Data_Collection Object(
    [_items:protected] =&gt; Array(
        [36] =&gt; Varien_Object Object(
            [_data:protected] =&gt; Array(
               [url] =&gt; http://blabla.com.br/blabla/media/catalog/product/1/3/133.jpg

我需要这个网址,但我不知道要找她

2 个答案:

答案 0 :(得分:2)

你可以使用如下

<?$_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();?>
<?if($_images){?>           
   <?$i=0; foreach($_images as $_image){ $i++;?>
      <a href="#"><img src="<?=$this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(200, 130); ?>" width="200" height="130" alt="<?=$this->htmlEscape($_image->getLabel());?>" title="<?=$this->htmlEscape($_image->getLabel());?>" /></a>              
   <?}?>
<?}?>

希望这对您有用,

答案 1 :(得分:0)

这应该这样做:

foreach ($_images as $image){
    echo $image->getUrl().'<br />';
}