Magento – Magento 2 – Limit reviews shown on product page

collection;magento-2.0.7magento2pagerreview

I'm looking for some help with limiting the review list on the product page to 5 reviews at a time.
I'm using Magento 2.0.7 and Porto 2.2.1

I found some suggestions on here but they were for Magento 1.x and didn't help me. What I tried so far:

{theme}\Magento_Review\templates\product\view\list.phtml

changed:

$_items = $block->getReviewsCollection()->getItems();

to

$_items = $block->getReviewsCollection()->getItems()->setPageSize(5);

Result: No reviews shown at all. Payed around but got either no reviews or 10 as usual.

{theme}\Magento_Review\layout\review_product_lists.xml

changed:

<block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar"/>

to

<block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar">
    <argument name="setLimit" xsi:type="number">5</argument>
</block>

I also played around in the pager.phtml and even pager.php with similar changes but got no results. What did I miss?

edit: Thanks, so far. Tried both changes, unfortunately I still get 10 reviews. Any chance that I need to change something somewhere else that I haven't noticed yet?
Yes, cache was flushed, other changes were visible immediately.

edit: I experimented with application\magento\vendor\magento\module-theme\Block\Html\Pager.php and found out that changing $_availableLimit or $_limit brings the desired results BUT that's not the clean way to work on this. Is there anything I missed? Is the class correct? Is the argument correct at all?

Best Answer

Your idea was good the order was wrong though.

Basically you have to change your first code:

$_items = $block->getReviewsCollection()->getItems()->setPageSize(5);

By:

$_items = $block->getReviewsCollection()->setPageSize(5)->getItems();

Regarding the pager, I think your syntax is wrong and instead of:

<block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar">
    <argument name="setLimit" xsi:type="number">5</argument>
</block>

It should be:

<block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar">
    <action method="setLimit">
        <argument name="limit" xsi:type="number">5</argument>
    </action>
</block>