1

How to override the pagination, sort by, Show per page in the phtml of magento2?

How to override the same in our custom module?

enter image description here

enter image description here

Need help in overriding the correct phtml and layout files!

This is what i tried!

Had overridden : Vendor\Module\Block\Product\ProductList\Toolbar.php

public function getPagerHtml()
{
   //as is
}

Vendor\Module\view\frontend\layout\catalog_category_view.xml

<?xml version="1.0"?>
  <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <!-- <referenceBlock class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" >
      <action method="setTemplate">
        <argument name="template" xsi:type="string">Vendor_Module::product/list/toolbar.phtml</argument>
      </action>
    </referenceBlock> -->
    <block class="Magento\Catalog\Block\Product\ListProduct" name="product_list" template="Magento_Catalog::product/list.phtml">
        <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
            <block class="Magento\Framework\View\Element\Template" as="default"/>
        </block>
        <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Vendor_Module::product/list/toolbar.phtml">
            <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
         </block>
         <action method="setToolbarBlockName">
             <argument name="name" xsi:type="string">product_list_toolbar</argument>
         </action>
    </block>
</body>
</page>

But for this i only get the pagination and other controls as shown:

enter image description here

  • Any update @Qaisar Satti – Sushivam Aug 18 '16 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.