I have a third party module in my magento 1 which is fetching products like this: $products = Mage::getModel('catalog/product')->getCollection(); So I want to replace it with selective products which are ordered in last 24 hrs. but the issue is I know how to fetch last 24 hrs orders but they are not returning items(products) ID or SKU. PLease let me know how to get products of last 24 hrs orders.

Here is my query of getting the orders:

$products = Mage::getResourceModel('sales/order_item_collection')
    ->addFieldToFilter('created_at', array(
    'from'     => strtotime('-1 day', time()),
    'to'       => time(),
    'datetime' => true

So how can I edit this to fetch product items instead of order items?

Thank you

1 Answer 1


If I want to add 'updated_at' too in the filter with the same condition like 'created_at' then what should I do in below query:

 $products = Mage::getResourceModel('catalog/product_collection')
                                    ->addFieldToFilter('created_at', array(
                                    'from'     => strtotime('-2 days', time()),
                                    'to'       => time(),
                                    'datetime' => true

Please help

Your Answer

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

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