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