UPDATE: this is partially answered(for someone who comes here lately).The answers does not updated the search filters.
I want to limit my product collection in any category/subcategory landing page with the help of a url parameter say itemlimit=10
I tried to do this in my phtml with setPageSize(3)
but this is setting the number of product in a page so the filters wont get modified accordingly.
Then i tried to do it with
$collection->getSelect()->limit(10);
and getting an error like this
Unrecognized method 'setCurPage()'
Am I doing the wrong thing? Should I override the catalog resource model collection for this?
EDIT:
This is my custom block class
class Ziva_Customcatalog_Block_Product_List extends Mage_Catalog_Block_Product_List {
public function __construct() {
parent::__construct();
}
protected function _getProductCollection() {
$collection = Mage::getModel('catalog/product')->getCollection();
return $collection->getSelect()->limit(10); // This will first 10 results
}
}
EDIT as asked: the entire trace
#0 C:\wamp\www\magento2\app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php(225): Zend_Db_Select->__call('setCurPage', Array)
#1 C:\wamp\www\magento2\app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php(225): Varien_Db_Select->setCurPage(1)
#2 C:\wamp\www\magento2\app\code\core\Mage\Catalog\Block\Product\List.php(158): Mage_Catalog_Block_Product_List_Toolbar->setCollection(Object(Varien_Db_Select))
#3 C:\wamp\www\magento2\app\code\core\Mage\Core\Block\Abstract.php(862): Mage_Catalog_Block_Product_List->_beforeToHtml()
#4 C:\wamp\www\magento2\app\code\core\Mage\Core\Block\Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
.................................................. #27 C:\wamp\www\magento2\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #28 C:\wamp\www\magento2\app\Mage.php(683): Mage_Core_Model_App->run(Array) #29 C:\wamp\www\magento2\index.php(87): Mage::run('', 'store') #30 {main}