2013-04-12 93 views
0

在Magento中,有沒有人知道如何限制顯示在主要產品圖像下的縮略圖數量?如何限制Magento產品頁面中產品縮略圖的數量

這是很容易通過管理員控制的,或者我應該進入media.phtml並編輯php?

<div class="more-views"> 
     <ul> 
     <?php foreach ($this->getGalleryImages() as $_image): ?> 
     <li> 
      <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;"> 

       <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(103, 103); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/> 
</a> 
     </li> 
    <?php endforeach; ?> 
    </ul> 
</div> 

回答

1

的最快方法是

<div class="more-views"> 
     <ul> 
     <?php $limit = 5; ?> 
     <?php $ct = 0; ?> 
     <?php foreach ($this->getGalleryImages() as $_image): ?> 
     <li> 
      <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;"> 
       <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(103, 103); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/> 
      </a> 
     </li> 
     <?php 
      if(++$ct >= $limit) 
      break; 
     ?> 
    <?php endforeach; ?> 
    </ul> 
</div> 
+0

這正是我所期待的。將其包裝在for循環中並針對變量$ limit運行。我很困惑:'$ ct = 0'正在被使用。 –

+0

爲了保持已經顯示多少圖像的計數,因爲我使用的是「foreach」循環而不是「for」循環。由於'getGalleryImages()'返回一個對象,該對象的索引可能不是從0開始,而是在中間 –

0

是的,你可以很容易地通過管理,您想要的主要產品圖片下顯示其圖像控制,但你需要的所有產品設置個別。

只需轉到添加/編輯產品的圖像選項卡。點擊您不想在圖庫上顯示的排除複選框,然後點擊保存按鈕。