Some times clients demand to show new arrivals product on home page or product listing page in magento store. Then its very easy to show that
For this load product collection and apply these filters
For this load product collection and apply these filters
<?php
/*Find the current date */
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
/*Making collection of new arrivals*/
$_productCollection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*') ->setStoreId($storeId) ->addStoreFilter($storeId) ->addCategoryFilter($category) ->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', $this->getRequest()->getParam('dir')); ?>
Comments
Post a Comment