Friday, 18 November 2016

Magento add toolbar and pager to custom product collection

Magento add toolbar and pager to custom product collection

Create toolbar object like:-

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

Then Assign product collection to toolbar object :-

$toolbar->setCollection($_productCollection);
$layout = Mage::getSingleton("core/layout");

Then set pager to toolbar as a child for show with pagination:-

$pager = $layout->createBlock("page/html_pager");

$toolbar->setChild("product_list_toolbar_pager", $pager);
echo $toolbar->toHtml();  

No comments:

Post a Comment