OK, this is probably not the perfect solution, but this is one way to get what you need.
This is how I got a collection of products that were on sale, where the final price of the product is lower than its price.
First, I did a new empty data collection. Then I determined the collection in which I was going to get filtered, first of all. After that I went in cycles in this collection, and all products which corresponded to my requirements, were added to an empty collection.
$this->_itemCollection = new Varien_Data_Collection(); $collection = Mage::getResourceModel('catalog/product_collection'); $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()); $category = Mage::getModel('catalog/category')->load($this->getCategoryId()); $collection = $this->_addProductAttributesAndPrices($collection) ->addStoreFilter() ->addCategoryFilter($category) ->addAttributeToSort('position', 'asc'); $i=0; foreach($collection as $product){ if($product->getFinalPrice() > $product->getPrice() && !$this->_itemCollection->getItemById($product->getId())){ $this->_itemCollection->addItem($product); $i++; } if($i==$this->getProductsCount()){ break; } } $this->setProductCollection($this->_itemCollection);
source share