I’m trying to get product collection of all products that has special_price and their special_to_date is less than today’s date, and they belong to a specific category. I tried the bellow code but it goes through a loop.
$products = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id',
'catalog/category_product',
'category_id',
'product_id = entity_id',
null)
->addFieldToFilter('category_id', 122)
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', array('neq' => 1))
->addAttributeToFilter('status', 1)
->addFieldToFilter('special_price',array('notnull'=>true))
->addFieldToFilter('special_to_date',array('lt'=> Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('today')) ))
->load();
Is anyone have an idea what I miss here.
Thank you all :))