0

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')
    ->addAttributeToSelect('*')
    ->addFieldToFilter('created_at', array(
    'from'     => strtotime('-1 day', time()),
    'to'       => time(),
    'datetime' => true
))
    ->load();

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

Thank you

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')
                                    ->addAttributeToSelect('*')
                                    ->addFieldToFilter('created_at', array(
                                    'from'     => strtotime('-2 days', time()),
                                    'to'       => time(),
                                    'datetime' => true
                                ))->load();

Please help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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