Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

toolbar not respecting collection size / page attributes
 
rgoodrow
Member
 
Total Posts:  31
Joined:  2013-04-23
 

So I’ve overloaded the Mage_Catalog_Block_Product_List with the following function in order to handle an additional filter paramter to the collection

class My_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List {
    
    
protected function getProductCollection() {
        
        
//$collection = parent::_getProductCollection();
        
$collection $this->_productCollection;
        
$collection->clear();
        
$a $this->getRequest()->getParam('a');
        if (
$a != ''{
            $collection
->addAttributeToFilter('name', array('regexp' => array('^['.substr($a01).'-'.substr($a11).']')));
        
}
        $collection
->setPageSize(12);
        
$collection->load();
        
$this->_productCollection $collection;
        
        
        return 
$this->_productCollection;
    
    
}
   
}

Within my Toolbar, I’m instantiating it and feeding it the resulting product collection

$toolbar $this->getLayout()
                        ->
createBlock('my/product_grid_toolbar')
                        ->
setTemplate('catalog/product/grid/toolbarAlpha.phtml')
                        ->
setCollection($_productCollection)
        ;
        echo 
$toolbar->toHtml();
along with a foreach loop to iterate through the returned products
foreach ($_productCollection as $_product{
   
// do stuff
}

the foreach loop correctly only displays 12 items, as well as the proper page of the collection. (items 13-24 on page 2, etc..)
however the toolbar shows the count as the full collection (size before adding the custom filter above), as well as displaying the full pagination for the full collection.

How can I get the toolbar to respect the filtered collection size fed to it?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top