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

Pagination for custom product collection
 
calvinc
Jr. Member
 
Total Posts:  11
Joined:  2010-01-05
 

Hi everyone,

I created a custom product collection using addAttributeFilters. However, I see that the pager toolbar is not working for my custom product collection.

Default magento uses: this->getLoadedProductCollection

I used the follownig code to filter a specific attribute value (in this example color):

$_productCollection Mage::getModel('catalog/category')->load($currentCategoryId)
    ->
getProductCollection()
    ->
addAttributeToSelect('*')
    ->
addFieldToFilter($filter_color);

Magento seems to just ignore the pager settings and show me all the products in the custom collection

Anyone know how to fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
calvinc
Jr. Member
 
Total Posts:  11
Joined:  2010-01-05
 

bump

any hints ? =/

 
Magento Community Magento Community
Magento Community
Magento Community
 
JohnBueno
Jr. Member
 
Total Posts:  3
Joined:  2012-07-10
 

Hey did you ever figure this one out?  I am having the same trouble.  I am creating a custom product collection:

$_productCollection = clone $this->getLoadedProductCollection();
    
$_productCollection->clear()
       ->
addAttributeToSelect('*')
       ->
addFieldToFilter(
        
'sale',
            array(
                
'eq' => Mage::getResourceModel('catalog/product')
                 ->
getAttribute('sale')
                 ->
getSource()
                 ->
getOptionId('Full Price')
            )
        )
        ->
setCurPage(1)
        ->
setPageSize(9999)
        ->
load();

The collection is what its suppose to be but my pagination still displays as if it was the full product collection rather than the filtered one.  Clicking on the pagination controls does nothing.  I have been stumped on this one for a while so any incite would be much appriciated!

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