I want to move toolbar above column. I am using this code:

<move element="product_list_toolbar" destination="columns.top" before="-" />

I am getting the getSize() error:

Fatal error: Uncaught Error: Call to a member function getSize() on null in /app/design/frontend/Digital/theme/Magento_Catalog/templates/product/list/toolbar.phtml:18

  • Where u Want toolbar please explain or provide your toolbar.phtml code.. – Magento_Bhurio Jun 22 '19 at 11:08
  • it is default toolbar.phtml, I am using this code in catalog_category_view.xml – Vinod Kumar Jun 22 '19 at 11:09
  • Where U want toolbar ? – Magento_Bhurio Jun 22 '19 at 11:11
  • Above product_list and layered_navigation – Vinod Kumar Jun 22 '19 at 11:15
  • Currently, this is showing: nimb.ws/Rz62qH . But I want to show like this: nimb.ws/I35VDL – Vinod Kumar Jun 22 '19 at 11:20

Copy catalog_category_view.xml into your Theme

    <referenceContainer name="columns.top">
             <block class="Magento\Catalog\Block\Category\View" name="custom-category.products" template="Magento_Catalog::category/products.phtml">
             <block class="Magento\Catalog\Block\Product\ListProduct" name="custom-category.products.list" as="product_list" template="Magento_Catalog::product/list1.phtml">
              <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
                <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
                <action method="setToolbarBlockName">
                    <argument name="name" xsi:type="string">product_list_toolbar</argument>

Then create product/list1.phtml file into your theme.

            $_productCollection = $block->getLoadedProductCollection();
            $_helper = $this->helper('Magento\Catalog\Helper\Output');
        <?= $block->getToolbarHtml() ?>

final in product/list.phtml remove or comment its.

        <?= $block->getToolbarHtml() ?>

Your Answer

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

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