2

I would like to remove the tool bar from my theme since I don't have that many products.

So far I have tried this in my /app/design/frontend/VENDORNAME/THEME/Magento_Theme/layout/default.xml

    <referenceBlock name="product_list_toolbar" remove="true"/>

Also I tried to replace /app/design/frontend/VENDORNAME/THEME/Magento_Theme/templates/html/pager.html with a empty file.

8

Removing the toolbar can be done in current theme dir by commenting in

Magento_Catalog/templates/product/list.phtml

the 2 lines with

<?php echo $block->getToolbarHtml() ?>

To hide it only in category page than wrap getToolbarHtml() with an if statement.

<?php if (!$this->getMyHideFlag()): ?>
  <?php echo $block->getToolbarHtml() ?>
<?php endif; ?>

In custom module's layout/catalog_category_view.xml add 'my_hide_flag' argument (or use layout instruction <action>). Set this 'my_hide_flag' to 1. Reference the block 'category.products.list'. http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-instructions.html

Toolbar block is called in

\Magento\Catalog\Block\Product\ProductList::_beforeToHtml.

Removing the toolbar and than calling toolbar block object in _beforeToHtml may trigger fatal errors.

Or hide the toolbar from css/less. Magento default css/less hides sorter, limiter, pages and view mode in top and bottom tollbars.

  • I have tried hiding sorter from css but its not working. – Siva Aug 8 at 7:34
2

Add it to catalog_category_view.xml layout in you custom theme

/app/design/frontend/VENDORNAME/THEME/Magento_Catalog/layout‌​/

Then clear cache and toolbar will disappear

<referenceBlock name="product_list_toolbar" remove="true" />
  • please try to describe your answer. And if you are not sure with your answer its better to write a comment instead of posting it as an answer. – Priyank Mar 20 '17 at 10:37
  • Perfectly normal answer! the only thing, replace display="false" with remove="true" and works like a charm – Devtype Aug 3 '18 at 21:37
1

Another way is to change the template file of the toolbar.

Create a new blank file in /<theme_dir>/Magento_Catalog/templates/blank.phtml

Update the toolbar template via catalog_category_view.xml

<referenceContainer name="content">
    <referenceBlock name="product_list_toolbar" template="Magento_Catalog::blank.phtml" />
</referenceContainer>

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.