I need to modify the product collection on category page. Therefore, I've modified the _getProductCollection() in Mage/Catalog/Block/Product/List.php and added an additional filter $this->_productCollection->addAttributeToFilter('entity_id', $prods);

But this works only partly.

The product count in the top bar shows the correct product count (10) but Magento shows 12 products for this category.

printing the variables in catalog/product/list.phtml shows up following result:

echo $_productCollection->count() // 12 [wrong]
echo $_productCollection->getSize() // 10 [correct]
echo $_productCollection->getSelect() // Running in db: 10 [correct]
iterating through the products with foreach ($_productCollection as $_product) shows 12 [wrong]

What am I doing wrong? Thanks!

1 Answer 1


Try to clear the product collection by adding following to your list.phtml, right after you load the collection.


This should resolve your issue


I recommend to overwrite the Block rather than copy it to app/code/local/Mage

To do so, just create your little extension




class Your_Extension_Block_Product_List extends Mage_Catalog_Block_Product_List 
    protected function _getProductCollection()
        $customCollection = parent::_getProductCollection();

        // Your logic

        $this->_productCollection->addAttributeToFilter('entity_id', $prods);

        return $this->_productCollection;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.