Magento how to sort by new products first -


i try use below code code give new product , need new product firs , other prodct.

$todaydate  = mage::app()->getlocale()->date()->tostring(varien_date::datetime_internal_format);  $collection = mage::getmodel('catalog/product')                 ->getcollection()                                    ->addattributetofilter('news_from_date', array('date' => true, 'to' => $todaydate))                 ->addattributetofilter('news_to_date', array('or'=> array(                     0 => array('date' => true, 'from' => $todaydate),                     1 => array('is' => new zend_db_expr('null')))                 ), 'left')                 ->addattributetosort('news_from_date', 'desc')                 ->addattributetosort('created_at', 'desc');  

any 1 idea ??

thanks in advance!!!

install extension sort date

see following step define in image

enter image description here


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -