enter image description here

I display custom products in page. use controller ,block and .phtml files define block and template in xml file.

Products are showing correctly i use template module/catalog/view/frontend/template\product\list.phtml .

Now i want to apply pagination and iuse many solution like

how to add pagination on custom collection in Magento 2




All these solution just show limited products on page but not show next page counting toolbar.

Can anyone help me please ? i already spend too much time

1 Answer 1


enter image description here

In Your .phtml file :-

<?php if ($block->getPagerHtml()): ?>
    <div class="order-products-toolbar toolbar bottom"><?php echo $block->getPagerHtml(); ?></div>
<?php endif ?>

Block file :-

namespace Vendor\Module\Block;

use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\View\Element\Template;

class ClassName extends \Magento\Framework\View\Element\Template

    protected $YourFactory;

    protected $_storeManager;

    public function __construct(Template\Context $context,
                                StoreManagerInterface $storeManager,
                                \Vendor\Module\Model\YourFactory $YourFactory,
                                array $data = [])
        $this->_storeManager = $storeManager;
        parent::__construct($context, $data);

    public function _prepareLayout()
        $this->pageConfig->getTitle()->set(__('Your Title'));

        if ($this->getTestimonials()) {
            $pager = $this->getLayout()->createBlock(
            $this->setChild('pager', $pager);
        return $this;
    public function getPagerHtml()
        return $this->getChildHtml('pager');

    public function getYourFunction()
        $page=($this->getRequest()->getParam('p'))? $this->getRequest()->getParam('p') : 1;
        //get values of current limit
        $pageSize=($this->getRequest()->getParam('limit'))? $this->getRequest
        ()->getParam('limit') : 12;
        $collection = $this->yourFactory->create()->getCollection();
        return $collection;

  • Dear Rk ? what is the difference in your answer and links which i mention in my question ?
    – HaFiz Umer
    May 9, 2019 at 5:42
  • "just show limited products on page but not show next page counting toolbar. " this line not understand please explain this May 9, 2019 at 5:45
  • Sir please check screenshot in my question . i want to navigation for next page.
    – HaFiz Umer
    May 9, 2019 at 5:58
  • Sir i want to pagination for next page. ex. page 1 2 3 4 >
    – HaFiz Umer
    May 9, 2019 at 6:01
  • check screen shot i hve used this code in my site May 9, 2019 at 6:03

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.