0

How can in override the Block file.I need to override the below file.

vendor/magento/module-theme/Block/Html/Pager.php

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

Also, I need to show 2 reviews per 1 page then what is the limit which will I have to set for above?

Please help me !!!

1 Answer 1

0

For Overriding files:

Vendor/Module/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
     <preference
            for="vendor\magento\module-theme\Block\Html\Pager"
            type="Vendor\Module\Block\Html\Pager"
    />
</config>

Then in Vendor\Module\Block\Html\Pager.php

<?php

namespace Vendor\Module\Block\Html;

class Pager extends \vendor\magento\module-theme\Block\Html\Pager {
 //do whatever you like
}

then run commands:

php bin/magento setup:di:compile

also run upgrade if you installing module first time

Your Answer

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

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