Tuesday 12 May 2015

Magento filter category product collection by special price and date.

You can add this is any phtml files.

 <?php
 $currentCatId = Mage::registry('current_category')->getParentCategory()->getId();
 $_productCollection = Mage::getModel('catalog/category')->load($currentCatId)
               ->getProductCollection()
               ->addAttributeToSelect('*') // add all attributes - optional
               ->addAttributeToFilter('status', 1) // enabled
               ->addAttributeToFilter('visibility', 4) //visibility in catalog,search
               ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
               ->addAttributeToFilter('special_to_date', array('or'=> array(
            0 => array('date' => true, 'from' => $tomorrowDate),
            1 => array('is' => new Zend_Db_Expr('null')))
            ), 'left');
 ?>

No comments:

Post a Comment