I have created a custom module. The
custom.phtml file lists all the products of a category and subcategory. I want to place toolbar with sort by price on the top of the category.
I have included the toolbar using the following code in
$category = new Mage_Catalog_Model_Category(); $category->load($catid); // My parent category id is 15 $prodCollection = $category->getProductCollection() ->addAttributeToSort('name', 'asc'); //gives me collection of products from parent as well as products of subcategory $toolbar = Mage::getBlockSingleton('catalog/product_list')->getToolbarBlock(); $toolbar->setCollection($_productCollection); $toolbar->setChild('product_list_toolbar_pager'); echo $toolbar->toHtml();
List and grid view is working but Sort by is not working in custom phmtl Collection to pass to toolbar to work??.