1

I have created a CMS page in Magento 2.1.7 back end, and added the following widget:

{{widget type="Magento\CatalogWidget\Block\Product\ProductsList"
show_pager="1" products_per_page="9" products_count="100"
template="product/widget/content/grid.phtml"
conditions_encoded="a:1:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]]"
page_var_name="pdfxop"}}

for showing all the products added in website. But in this CMS page the toolbar is not showing up. Pagination is there in the footer. But not toolbar on top of the product listing. How can I do this? Can any one please help me?

2 Answers 2

2

First you need to create a toolbar object as shown below in your phtml file

$toolbar = Mage::getBlockSingleton('catalog/product_list')->getToolbarBlock();

Then Assign product collection to toolbar object

$toolbar->setCollection($_productCollection);

echo $toolbar->toHtml();

0

Override widget template, copy

/vendor/magento/module-catalog-widget/view/frontend/templates/product/widget/content/grid.phtml

to your custom theme:

your_theme_root/Magento_CatalogWidget/templates/product/widget/content/grid.phtml

Then insert the call of pager on top of the product listing, where you want to see it:

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

I hope it helps.

2
  • Thanks for your reply. but will it affect in other areas? suppose if I have a grid in home page to show featured products and I don't need tool bar in home page. When I make this change the home page will also show the toolbar?
    – hakkim
    Commented Oct 19, 2017 at 9:17
  • You may set parameter show_pager="0" in the widget call for homepage and pager is shouldn't show Commented Oct 19, 2017 at 9:27

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.