获取过去24小时在Magento的订单商品 [英] Get orders items from last 24 hours in Magento

查看:62
本文介绍了获取过去24小时在Magento的订单商品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取过去24小时内的所有订单商品.我已将查询锁定,因此它可以将我需要的东西(order_id和created_on值)还给我.

I'm attempting to get all order items from the last 24 hours. I have the query locked down, so it's giving me back what I need (an order_id, and created_on value).

$order_items = Mage::getResourceModel('sales/order_item_collection')
    ->addAttributeToSelect('order_id')
    ->addAttributeToSelect('created_at')
    ->addFieldToFilter('sku', $membership_sku)
    ->toArray();

我已经搜索了所有内容,看起来我需要添加另一个-> addFieldToFilter()属性,但是我不确定该如何构造.任何示例都将非常有帮助.

I've searched all over, and it looks like I need to add another ->addFieldToFilter() property, but I'm not quite sure how it should be structured. Any examples would be extremely helpful.

如果有帮助,我正在使用Magento Enterprise v1.12.0.2

If it helps, I'm using Magento Enterprise v1.12.0.2

推荐答案

我认为您需要重新格式化自己的时间才能获得良好的结果:

I think you will need to reformat your times to be able to get good results:

$time = time();
$to = date('Y-m-d H:i:s', $time);
$lastTime = $time - 86400; // 60*60*24
$from = date('Y-m-d H:i:s', $lastTime);
$order_items = Mage::getResourceModel('sales/order_item_collection')
    ->addAttributeToSelect('order_id')
    ->addAttributeToSelect('created_at')
    ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to))
    ->load();

这篇关于获取过去24小时在Magento的订单商品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆