Skip to content

Instantly share code, notes, and snippets.

@rahuldadhich
Created September 12, 2017 16:21
Show Gist options
  • Save rahuldadhich/7d0b4a974578221672a392f2f420b33c to your computer and use it in GitHub Desktop.
Save rahuldadhich/7d0b4a974578221672a392f2f420b33c to your computer and use it in GitHub Desktop.
Magento Sale Products
class Mage_Catalog_Block_Product_Mylist extends Mage_Catalog_Block_Product_List
{
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
$collection = parent::_getProductCollection();
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToSort('special_from_date', 'desc');
return $collection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment