2
我已經絆倒了一個多小時了,這意味着有時間尋求幫助!我在我的Magento主題中有一個自定義區域,用於顯示來自某個類別的4個產品 - 這是最暢銷的產品。該塊顯示了4種產品並且具有正確的鏈接,但是,其他細節似乎沒有加載,例如:名稱,價格,圖像和評分等......非常奇怪!Magento自定義product_list塊中的空白產品數據
這裏是我的XML位於在CMS指數設計:
<block type="catalog/product_list" name="tabs.products.best" as="bestSellers" template="page/html/home/best-sellers.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setLimit"><limit>4</limit></action>
<action method="unsetChild"><alias>product_list_toolbar</alias></action>
<action method="setCategoryId"><category_id>64</category_id></action>
</block>
這在模板文件中使用此功能:
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$_productCollection = Mage::getModel('catalog/product')
->getCollection()
->addCategoryFilter($category)
->setPageSize(4)
->load();
$_helper = $this->helper('catalog/output');
任何幫助深表感謝!
爲了縮短工作時間,可以使用'$ _productCollection = $ category-> getProductCollection();'來代替。它本質上是一樣的工作,但對你來說更少的努力。這並不能否定下面Jim的合理答案。 – clockworkgeek 2012-01-16 00:46:00