0

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

1 Answer 1

1

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.