2012-07-19 108 views
0

我想改變Magento處理產品圖像的方式。目前,在可配置產品上,它會顯示您已上傳到可確認產品的圖像。Magento Show相關產品圖像

我想要它,所以如果產品是可配置的,那麼它將只顯示相關產品的圖像,而不是上傳到配置產品的圖像。

在我的媒體文件,我有

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

    <li><a href="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(70, 70); ?>" width="70"/></a></li> 

<?php endforeach; ?> 

,我可以看到從配置產品的畫廊拉圖像,所以在某種程度上需要改變這個檢查,如果它是一個可配置的產品,那麼如果僅從相關產品中提取圖像。

我想檢查它是否可配置它會是這樣的?

<?php if ($_product->isSaleable() && (!$_product->isConfigurable() ?> 

然後將新的代碼拉到相關的產品圖片中,這是我需要的一點幫助。

+0

嘿馬特,你是否能夠得到這個工作,因爲我也試圖實現相同。我安裝了簡單的可配置產品擴展程序,現在想從可配置頁面中刪除下拉菜單,只列出相關產品的縮略圖,並根據縮略圖的選擇動態更改圖像。 – itsandy 2013-04-19 03:54:27

回答

0

通過在可配置產品上調用getAllowProducts(),可以從可配置中獲得一系列使用過的產品。

foreach ($_product->getAllowProducts() as $_associatedProduct) { 
    echo $this->helper('catalog/image')->init($_associatedProduct, 'image') 
     ->resize(340,260); 
} 
+0

如果我們在每個關聯產品中有多個圖像,您的循環是否會工作? – ankur140290 2016-01-02 09:11:43