2010-11-29 50 views
0

我有一個名爲「Top Products」的類別。我希望在我的主頁上的一個面板中顯示。在magento中做這件事的最好方法是什麼?如何編寫一個顯示magento類別的自定義面板

**編輯**

感謝sdek,我現在有以下。在主頁/設計。

<block type="catalog/product_list" category_id="13" template="catalog/product/featured.phtml"/> 

它正在顯示產品。不過,我有以下問題。 - 它不顯示來自category_id 13的產品,看起來像這個值沒有通過 - 它只顯示2個產品。我希望顯示所有。

featured.phtml

<?php 
    $_productCollection=$this->getLoadedProductCollection(); 
    $_helper = $this->helper('catalog/output'); 
?> 
<?php if(!$_productCollection->count()): ?> 
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p> 
<?php else: ?> 
<h2>Featured Products </h2> 
    <?php $_collectionSize = $_productCollection->count() ?> 
    <?php $_columnCount = $this->getColumnCount(); ?> 
    <?php $i=0; foreach ($_productCollection as $_product): ?> 
     <?php if ($i++%$_columnCount==0): ?> 
     <ul class="product-grid"> 
     <?php endif ?> 
      <li class="<?php if(($i-1)%$_columnCount==0): ?> first<?php else: ?> last<?php endif; ?>"> 
      <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" > 
      <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(85); ?>" class="product-img" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="padding-bottom:20px; margin-bottom:20px;" /> 
      </a> 
      <p><strong><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></strong> 
      <?php echo $_product->getShortDescription(); ?></p> 

      <?php echo $this->getPriceHtml($_product, true) ?> 
      <a href="<?php echo $_product->getProductUrl() ?>" class="more">More details</a> 
      </li> 
     <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?> 
     </ul> 
     <?php endif ?> 
     <?php endforeach ?> 
    <?php endif; ? 

回答

0

通過clockworkgeek提到的特色產品延伸是一個好主意。但是如果你不喜歡這個選項,最簡單的做法就是將它添加到你的主頁cms {{block type =「catalog/product_list」category_id =「YOUR_CAT_ID」template =「catalog/product/YOUR_MODIFIED_COPY_OF_LIST.phtml」 }}

然後使應用程序/設計/前端的拷貝/ / /template/catalog/product/list.phtml(I refered到它上面YOUR_MODIFIED_COPY_OF_LIST.phtml)並取下線那說

<?php echo $this->getToolbarHtml() ?> 

和刪除整個IF-塊輸出「列表模式」 ......基本上if語句

<?php // List mode ?> 
    <?php if($this->getMode()!='grid'): ?> 

並且您應該只有「網格模式」代碼。

+0

謝謝,真的很感謝回覆。對於magento很新穎。開始瞭解這一切如何融合在一起。你介意快速瀏覽一下上面的問題嗎?似乎無法得到正確的類別 – frosty 2010-12-05 11:25:27

相關問題