我正在使用此网址:http://xhtmlandcsshelp.blogspot.in/2010/12/get-products-from-particular-category.html
我需要在主页上显示特定类别ID的产品
所以我使用了那个网址,我补充说,
$model->load($_prdIds);
$pname = $model->getName();
但评级摘要明星如何显示?有人可以帮帮我吗?
提前致谢...
答案 0 :(得分:7)
测试并使用Magento 1.7.0.1
<?php
/**
* Instanciate reviews helper
*/
$this->_reviewsHelperBlock = $this->getLayout()->createBlock('review/helper');
/**
* Get products for your category
*/
$products = Mage::getModel('catalog/category')->load(YOUR_CATEGORY_ID)->getProductCollection();
/**
* Loop thru products
*/
foreach($products as $product) {
$product = Mage::getModel('catalog/product')->load($product->getId());
echo $product->getName();
/**
* Display review summary with stars.
* If correctly configured in back-office: Catalog > Reviews and Ratings > Manage Ratings
*/
echo $this->_reviewsHelperBlock->getSummaryHtml($product, false, false);
echo '<hr/>';
}
?>