我有以下代码来显示我商店中查看次数最多的产品。问题是产品显示没有任何图像(显示占位符图像)和名称。如果我从后端禁用Flat类别和Product,则会显示图像和产品名称,但我不允许禁用它。我不知道我错过了什么,请帮忙。
<?php
class Mage_Catalog_Block_Product_Viewed extends Mage_Catalog_Block_Product_Abstract{
public function __construct(){
parent::__construct();
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addMinimalPrice()
->addAttributeToSelect('*')
->addAttributeToSelect(array('name', 'price', 'small_image'))
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
$products->setPageSize(5)->setCurPage(1);
$this->setProductCollection($products);
}
}
?>