magento - 在 Magento 中获取过去 24 小时内的订单商品

标签 magento

我正在尝试获取过去 24 小时内的所有订单商品。我已锁定查询,因此它返回了我需要的内容(order_id 和created_on 值)。

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

我已经搜索遍了,看起来我需要添加另一个 ->addFieldToFilter() 属性,但我不太确定它应该如何构造。任何例子都会非常有帮助。

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

最佳答案

我认为你需要重新安排你的时间才能获得好的结果:

$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();

关于magento - 在 Magento 中获取过去 24 小时内的订单商品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14151134/

相关文章:

php - .htaccess 不适用于 Apache2

php - 如何设置表单字段的默认值-Magento?

php - 将产品添加到购物车之前的 Magento 事件

php - magento 1.5 产品评论存储在哪里?

magento - 如何自定义 magento View

Magento - 产品列表到 CMS 页面

url - magento 显示请求地址

mysql - Magento #1005 - 无法创建表 '...'(错误号 : 121) ERROR

javascript - 销售在 Magento 报告中不起作用

apache - 无法从 url magento 中删除 index.php 在 VPS 托管上