magento list page or search page add review count


//byfeng 
public function addReviewcount()
{
    $RecentviewSelect=Mage::getSingleton('core/resource')->getConnection('core_read')
    ->select()
    ->from($this->getTable('review/review'),array('review_count' => new Zend_Db_Expr('COUNT(*)'),'product_id'=>'entity_pk_value'))
    ->where("{$this->getTable('review/review')}.status_id = 1")
    ->group("{$this->getTable('review/review')}.entity_pk_value");

    $this->getSelect()->joinLeft(array('bs'=>$RecentviewSelect), 'bs.product_id = e.entity_id',
     array('review' => 'bs.review_count')); 

    return $this;
}

你可能感兴趣的:(magento list page or search page add review count)