How use Pagination in Custom Product Page

Delilah: 20 May 2022

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

Anthony: 20 May 2022

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;