I need to get all products that have set the SpecialToDate attribute.

I have a code but is not displaying any product.

 $_productCollection = Mage::getModel('catalog/product')->getCollection();

               ->where('price_index.final_price < price_index.price')
               ->addAttributeToFilter('SpecialToDate', 1);

I also tried to add a condition inside the foreach but is displaying only 2 products from 5. The 2 products are id 1 and 2, the other 3 products have ID 6001 and 6002, so like is not retrieve all special products.

 <?php foreach ($_productCollection as $product): 

        if($product->getSpecialToDate() != null) {


The attribute code is not valid as it is case sensitive in the method parameter.

You need to replace your code with:

addAttributeToFilter('special_to_date', $validDate);

Where $validDate must be a valid date

  • Can you explain how the $validDate should be? I tried with this $validDate = Mage::getModel('core/date')->date('Y-m-d'); – George George Jan 25 '17 at 11:34
  • @GeorgeGeorge try the date as Y-m-d H:i:s – JPK Jan 26 '17 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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