0

How to get Magento product reviews of status APPROVED and/or PENDING?

None of these attempts work. Anyone know how to achieve this?

$reviews = Mage::getModel('review/review')->getResourceCollection();
$reviews->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED && STATUS_PENDING)

or:

$reviews = Mage::getModel('review/review')->getResourceCollection();
$reviews->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED && Mage_Review_Model_Review::STATUS_PENDING)

or:

$reviews = Mage::getModel('review/review')->getResourceCollection();
$reviews->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED || Mage_Review_Model_Review::STATUS_PENDING)

What is the correct syntax to filter both Approved and Pending reviews?

So all reviews but excluding STATUS_NOT_APPROVED reviews

0

below code is correct

$reviews = Mage::getModel('review/review')->getResourceCollection();
$reviews->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED || Mage_Review_Model_Review::STATUS_PENDING)
  • Thanks, but that doesn't work for me, it seems to get all reviews regardless of status. My full code: $reviews = Mage::getModel('review/review')->getResourceCollection(); $reviews->addStoreFilter(Mage::app()->getStore()->getId()) ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED || Mage_Review_Model_Review::STATUS_PENDING) ->addEntityFilter('product', $_product->getId()) ->setDateOrder() ->addRateVotes() ->load(); $reviews = $reviews->getData(); – Dan Jan 23 at 17:35
  • means processing status review also coming? – Rakesh Donga Jan 23 at 17:40
  • Yes, reviews with STATUS_NOT_APPROVED are also included. It's like the addStatusFilter is ignored using that syntax – Dan Jan 23 at 17:41
  • you can try below code $reviews = Mage::getModel('review/review')->getCollection() ->addStoreFilter(Mage::app()->getStore()->getId()) ->addEntityFilter('product', $productId) ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED || Mage_Review_Model_Review::STATUS_PENDING) ->setDateOrder() ->addRateVotes(); – Rakesh Donga Jan 23 at 17:49
  • Nope couldn't get it working. Instead I added an if statement to ignore the review if status = 3 if (count($reviews)) { for ($i = 0; $i < count($reviews); $i++) { if ($reviews[$i]["status_id"] != 3) { //print review here } This works for me. Not pretty but gets the job done. – Dan Jan 23 at 18:20

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.