1

I'm using the allreviews Magento extension so that I have a page with all reviews however I need to add pagination to this page.

The last bit I'm stuck with is essentially adding the limit to the query. I've read a number of threads that say to use setCurPage on the collection but this doesn't seem to affect the query at all?

When I try what should equal LIMIT 25, 25 and LIMIT 75,25 etc I still get the result from LIMIT 0, 25

Current query:

//$_GET['product'] = 1;    //product id
$numberOfReviews = 25;     //per page
$page = 3;                 //page

$_reviews = Mage::getModel('review/review')
                        ->getCollection()
                        ->addFieldToFilter('entity_pk_value', $_GET['product'])
                        ->addStoreFilter(Mage::app()->getStore()->getId()) 
                        ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                        ->setDateOrder('desc')
                        ->setPageSize($numberOfReviews)
                        ->addRateVotes()
                        ->setCurPage($page);

What am I doing wrong?

2

I believe addRateVotes() loads the collection, try setCurPage() before that call.

Once a collection has been loaded, no changes can be made to it without first clearing it.

    public function addRateVotes()
    {
        foreach ($this->getItems() as $item) {
            $votesCollection = Mage::getModel('rating/rating_option_vote')
                ->getResourceCollection()
                ->setReviewFilter($item->getId())
                ->setStoreFilter(Mage::app()->getStore()->getId())
                ->addRatingInfo(Mage::app()->getStore()->getId())
                ->load();
            $item->setRatingVotes($votesCollection);
        }

        return $this;
    }
  • addRateVotes() at the end seemed to do the trick, thanks! – Dan Dec 11 '14 at 17:18

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.