2012-04-05 72 views
1

下面是在list.phtml中的類別頁面上獲取產品列表的代碼。magento中的list.phtml模板中的隨機產品

$_productCollection=$this->getLoadedProductCollection(); 
$_helper = $this->helper('catalog/output'); 

我想要列出此列表下方的另一部分,我可以列出任何類別的隨機產品。 我可以做些什麼來修改這個相同的函數並重用它嗎?

如果我可以使用相同的幫手,這將是非常簡單的。

我想要一個「你可能對這些感興趣」的部分,我在那裏展示隨機產品。

感謝 抗體

回答

1

我無法想象的東西在Magento是那樣簡單:

shuffle($_productCollection); 
0

在XML中,你應該定義塊,這樣的事情:

<block type="catalog/product_list_random" template="your random template" name="random" /> 

和在類別查看頁面只需打電話給您的模板,如

echo $this->getChildHtml('random');