I’m a newbie with Magento getResourceModel, and I’m trying to add a simple filter to my query, but i can’t figure that using getResourceModel.
Original Query:
$collection = Mage::getResourceModel('catalog/product_collection');
Mage::getModel('catalog/layer')->prepareProductCollection($collection);
$collection->addAttributeToFilter('promotion', 1)->setOrder('price', 'desc');
I just want add the where clause:
(`price` - `final_price`) >= (`price` * 0.4)
Someone can help me to do this?
This is all, thanks!
So finally I found the correct way to do this, sorry to delay to post the answer here and thanks @feeela.
Looking the file
/lib/Zend/Db/Select.phpI found that exists the where function:So, what we need is just add a call to this function giving the condition that we want. In my case, I just add a condition to filter products that have 40% of discount.
So, I hope that this can be helpful for some dudes!
Grazie tutti!