4
$productId = $my_product->getId();

$reviews = Mage::getModel('review/review')->getResourceCollection()
          ->addStoreFilter(Mage::app()->getStore()->getId())
          ->addEntityFilter('product', $productId)
          ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
          ->setDateOrder()
          ->addRateVotes();

Using this get all review & rating but want to get most rating star reviews

  • Can you please rephrase the last statement? It's not very clear what you're trying to achieve – Alex Dinca Jan 16 '16 at 16:15
3

This code will put reviews with higher rates on top:

$productId = $my_product->getId();
$reviews = Mage::getModel('review/review')->getResourceCollection()
          ->addStoreFilter(Mage::app()->getStore()->getId())
          ->addEntityFilter('product', $productId)
          ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
          ->setDateOrder()
          ->addRateVotes();

$reviews->getSelect()->joinInner(
    'rating_option_vote',
    'main_table.review_id = rating_option_vote.review_id',
    array('review_value' => 'rating_option_vote.value')
);
$reviews->getSelect()->order('review_value DESC');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.