现在已经磕了我一个多小时,这意味着有时间寻求帮助!我在Magento主题中有一个自定义块来显示一个类别的4个产品 - 这是畅销书。该块显示4个产品并具有正确的链接,但是,其他任何细节似乎都没有加载,例如:名称,价格,图像和评级等......非常奇怪!
这是我的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');
任何帮助都将深表感谢!
答案 0 :(得分:2)
尝试在 - &gt; load()之前添加此内容以加载默认属性集:
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
默认属性集应包括您在上面提到的所有字段(以及更多)。