測試和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/>';
}
?>
感謝Man..you好了工作.. – Dolly
喜,我能夠使用這種方法爲相關產品添加評論評分。謝謝! –