Question

How I can get new products of the last 30 days in Magento 1.9.

Was it helpful?

Solution

Here is an example you can try this, It will give you last added item of last 10 days.

require_once 'app/Mage.php';
Mage::app();
umask(0);
$date = Mage::getModel('core/date')->date('Y-m-d h:m:s');

$startDate =  Mage::getModel('core/date')->date('Y-m-d 0:0:0', strtotime($date." -10 days"));

$collection = Mage::getModel('catalog/product')
 ->getCollection()
 ->addFieldToFilter('created_at', array('from' => $startDate, 'to' => $date));
 $collection->addAttributeToSort('entity_id', 'DESC');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top