2012-09-11 71 views

回答

7

測試和Magento的1.7.0.1


Reviews on homepage


<?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/>'; 
    } 
?> 
+0

感謝Man..you好了工作.. – Dolly

+0

喜,我能夠使用這種方法爲相關產品添加評論評分。謝謝! –

相關問題