Magento – How to limit the product reviews shown in product page in magento 2

collection;frontendmagento2.2product-review

I have created review form as popup modal, And I have also removed reviews tab in product page. And I have created new section before footer which contains the collection of customer reviews which is shown in frontend, Now I need to Limit the reviews via xml, Please provide me a solution

Catalog_product_view.xml

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.info.review">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">XXX_YYY::review.phtml</argument>
            </action>
            <!--To display popup and form-->
            <block class="Magento\Review\Block\Form" name="custom.review.popup" template="XXX_YYY::popup.phtml">
                <block class="Magento\Review\Block\Form" name="custom.product.review.form" as="custom.review_form" template="XXX_YYY::form.phtml">
                    <container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>
                    <arguments>
                        <argument name="jsLayout" xsi:type="array">
                            <item name="components" xsi:type="array">
                                <item name="review-form" xsi:type="array">
                                    <item name="component" xsi:type="string">Magento_Review/js/view/review</item>
                                </item>
                            </item>
                        </argument>
                    </arguments>
                </block>
            </block>
        </referenceBlock>
        <!--Removes the review tab-->
        <referenceBlock name="product.info.details">
            <referenceBlock name="reviews.tab" remove="true" />
        </referenceBlock>
        <!--Display Customer reviews collection-->
        <referenceContainer name="product.info.additional">
            <block class="Magento\Review\Block\Product\View\ListView"  name="custom.product.section.info" template="XXX_YYY::customer-reviews.phtml"/> 
        </referenceContainer>
    </body>
</page>

Best Answer

Override Magento\Review\Block\Product\View\ListView file using di.xml with below code:

/**
 * Prepare product review list toolbar
 *
 * @return $this
 */
protected function _prepareLayout()
{
    parent::_prepareLayout();
    $toolbar = $this->getLayout()->getBlock('product_review_list.toolbar');
    if ($toolbar) {
        $toolbar->setLimit(1);
        $collection = $this->getReviewsCollection();

        $toolbar->setCollection($collection);
        $this->setChild('toolbar', $toolbar);
    }

    return $this;
}

Note: all protected methods should which rquired to use should be in your class. Remove toolbar code from xml which is in Magento_Review > module > view -> frontend > layout > catalog_product_view.xml