2012-04-14 61 views
1

我可以看到media.phtml(帶有Cloud Zoom擴展)如何在$ this-> getGalleryImages()的幫助下列出產品頁面上的所有圖像:Magento:顯示產品頁面上的所有圖像(view.phtml)

<?php foreach ($this->getGalleryImages() as $_image): ?> 
<?php ... ?> 
<?php endforeach; ?> 

但是,當我在view.phtml這是產品目錄頁面模板使用$這 - > getGalleryImages(),它不返回或輸出任何東西。然而,這隻能打印產品頁面上的第一個圖像:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->setWatermarkImageOpacity(0)->resize(300, null);?>" alt="<?php echo $this->htmlEscape($this->getImageLabel());?>" title="<?php echo $this->htmlEscape($this->getImageLabel());?>" /> 

我的問題是我怎麼能遍歷並顯示產品頁面上的所有產品圖片(view.phtml,不media.phtml)?基本上,我希望他們都在頁面上顯示,而不用縮略圖或縮放或任何東西,只是簡單的大圖像,一個接一個。

謝謝!

回答

11

這裏是用於表示商品圖像庫中的代碼..

謝謝, 截拳道

<?php $_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages(); ?> 
<?php if($_images){?>    
    <?php $i=0; foreach($_images as $_image){ $i++; ?> 
     <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(108,90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel());?>" title="<?php $this->htmlEscape($_image->getLabel());?>" /><?php } ?> 
    <?php } ?> 
相關問題