Building a “New Arrivals” Product List in Magento

Building a “New Arrivals” Product List in Magento

Magento 1 lets merchandisers mark products as new with the Set Product as New From and To dates. You can use those dates to build a new arrivals section on the home page or anywhere else.

The collection

This loads products whose “new from” date has started and whose “new to” date has not yet passed (or is empty):

<?php
$todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
 
$_productCollection=$this->getLoadedProductCollection();
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->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');
 
$now = date("Y-m-d");
$newsFrom= substr($_productCollection->getData('news_from_date'),0,10);
$newsTo=  substr($_productCollection->getData('news_to_date'),0,10);

?>

Loop over $_productCollection in your template to output names, images and prices. Add a page size limit if you only want to show the latest few products.

Heads up: this guide applies to Magento 1, which stopped receiving official security updates in June 2020. If your store still runs it, plan a move to Magento 2 or Adobe Commerce soon. We can help with the migration.

Stuck on something similar? Our Magento development team is happy to take a look.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.