paginationtoolbarmagento-1.7

Magento pagination not working in custom module


I have a very complex problem (at least i think so) implementing a custom module in Magento. I have created a module that displays products of a single main category in default catalog. For example,

root catalog
  -main category
     -cat 1
     -cat 2
       -sub category 1
     -cat 3

So what i need to do is, display all these categories in a drop down list and when you select any one category all its products will be loaded. Seemed pretty strait forward. I added the code to display this sort by category drop down list in my module's list.phtml file. Instead of loading default product collection I loaded the main category and then fetched all its sub category and populated the drop down list. And I fetched the product collection of the selected category from the drop down list. My code is like this:

$baseCategory = Mage::getModel('catalog/category')->load(62);
$_productCollection = $baseCategory->getProductCollection()->addAttributeToSelect('*');

The products are loaded alright but the problem arises with pagination. the code for pagination goes like this:

$this->getToolbarHtml();

I have used the $this->getToolbarHtml(); instead of $this so in pagination also I need to change the object. It's not working due to that I think. The toolbar is shown but regardless of number of products per page selected it always displays all products. Can anyone tell me please how to get the toolbar working with my changed code in list.phtml file?


Solution

  • I've found a different approach to the task i wanted to accomplish. So instead of creating a new module i created a new theme and so just overridden the list.phtml file. There is no need to use the above code anymore. And since i am using the default catalog object the pager is also loaded alright.