I want to set pagination in product review tab. So if I have 30 reviews for particular product, then in reviews tab I want the pagination from 1 to 5 with next and previous buttons and in all pages I want to show only 5 review/page.

On this path vendor/magento/module-review/Block/Product/View I got block file ListView.php. File code is below.

protected function _prepareLayout()

    $toolbar = $this->getLayout()->getBlock('product_review_list.toolbar');
    if ($toolbar) {
        $this->setChild('toolbar', $toolbar);

    return $this;

Above is the review collection code so how to change this code so I can set pagination?

4 Answers 4

Magento 2 Default provide Pagination in Review Tab. If you want to Set Limit in review than change in below file.  

find Below Code in Pager.php

 protected $_availableLimit = [10 => 10, 20 => 20, 50 => 50];

Replace With 

 protected $_availableLimit = [5 => 5, 10 => 10, 25 => 25];

It's Working to Set Limit in Review Tab.


All of the solutions above assume that you will never update, or reinstall your magento.

You shouldn't edit anything in vendor directory. Ever!

There are better solutions. In your specific case, you can use that in if statement provided above.


Assuming that your collection still haven't been loaded.

If it have been, I would recommend adding plugin overwritting your default layout.


You will need to override block file /vendor/magento/module-theme/Block/Html/Pager.php and find code like this:

protected $_availableLimit = [10 => 10, 20 => 20, 50 => 50];

Then you need to add extra limit value (which is 5 in your case) like this:

protected $_availableLimit = [5 => 5, 10 => 10, 20 => 20, 50 => 50];

Please let me know if you have any question.

  • this will change the pagination for everything.
    – Marius
    Jul 22, 2016 at 6:07
  • @Marius I only want to set pagination for product reviews tab. how can I do that?
    – Dhaval
    Jul 22, 2016 at 6:20
  • Have you tried it or not? Jul 22, 2016 at 6:25
  • I don't think it will change pagination for every thing because for products there is setting in admin panel and when limit parameter value is set from admin panel (for products), then it will not affect in other places. Jul 22, 2016 at 6:25
  • @MohitKumarArora if I want to add pagination in product reviews tab only then I need to change in above code that I added in my question on anywhere else?
    – Dhaval
    Jul 22, 2016 at 6:45

For example you want pagination of 5 per page. Make these changes.

in app/code/Vendor/Module/etc/di.xml

<preference for="Magento\Theme\Block\Html\Pager" type="Vendor\Module\Plugin\UpdatePagerClass" />

and in app/code/Vendor/Module/Plugin/UpdatePagerClass.php

namespace Vendor\Module\Plugin;

use Magento\Theme\Block\Html\Pager;

class UpdatePagerClass extends Pager
     * Retrieve pager limit
     * @return array
    public function getAvailableLimit()
        for($i=4; $i<=100; $i+=5){
        return $limits;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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