For my custom module I have get product by manufacturer. For template I have copied list.phtml
.
On the template file pagination appears but it shows all product instead of selected limit per page. Sorting is not working too.
How can I make it work??
It is my block file:
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();
$brand_id = $this->getRequest()->getParam('id');
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addFieldToFilter(array(
array('attribute' => 'manufacturer', 'eq' => $brand_id)
));
}
return $collection;
}
Best Answer
Use below snippet to add pagination and sorting on your custom collection. For every custom collection listing you have to create custom toolbar pager as well.
After this, replace
to display bottom pager and top sorting toolbar.
For sorting order, do this before collection load:
I hope this resolves your problem.