在Magento中获取状态为“已完成"的订单ID [英] Get order ids with status = 'Complete' in Magento

查看:85
本文介绍了在Magento中获取状态为“已完成"的订单ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Magento中的状态为'complete'的订单获取订单ID和其他详细信息.我确信magento中有一种方法可以检索状态为完成"的所有订单.因为我是magento的新手,所以我很难解决这个问题.

I am working on getting order ids and other details for orders with status ='complete' in Magento. I am sure there is a way in magento where we can retrieve all orders with status as Complete. Since I am a new-bie to magento I am finding it hard to work this out.

我想向客户发送订单状态为完成电子邮件",并在发送电子邮件后将其标记.但这就是它的后半部分.谁能告诉我如何在magento中获取状态为完成"的所有订单ID?

I would like to send the customers with order status as Complete an email and mark them once an email is sent. But thats the later part of it. Can any one tell me how in magento can you get all order id's with status as Complete ?

感谢您的帮助.提前致谢.

Any help is appreciated. Thanks in advance.

推荐答案

这可以作为基本Magento安装文件夹中的脚本运行.如果它已经在Magento文件中运行了(控制器,块或其他文件),则不需要前三行.

This can be run as a script from the base Magento install folder. If its running inside of a Magento file already (controller or block or whatever) you don't need the first three lines.

<?php
require_once('app/Mage.php');
Mage::app();

$orders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('status', 'complete')
    ->addAttributeToSelect('customer_email')
    ;
foreach ($orders as $order) {
    $email = $order->getCustomerEmail();
    echo $email . "\n";
}

要查看带有状态和电子邮件的所有订单:

To see all orders with statuses and emails:

$orders = Mage::getModel('sales/order')->getCollection()
    //->addFieldToFilter('status', 'complete')
    ->addAttributeToSelect('customer_email')
    ->addAttributeToSelect('status')
    ;
foreach ($orders as $order) {
    $email = $order->getCustomerEmail();
    echo $order->getId() . ": '" . $order->getStatus() . "', " . $email . "\n";
}

这篇关于在Magento中获取状态为“已完成"的订单ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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