获取状态=“完成”的订单 ID在 Magento 中

发布于 2024-12-18 22:23:04 字数 236 浏览 1 评论 0原文

我正在努力获取 Magento 中状态为“完整”的订单的订单 ID 和其他详细信息。我确信在 magento 中有一种方法可以检索所有状态为“完成”的订单。由于我是 magento 的新手,我发现很难解决这个问题。

我想向订单状态为完成的客户发送一封电子邮件,并在发送电子邮件后对其进行标记。但这是它的后面部分。谁能告诉我如何在 magento 中获取状态为 Complete 的所有订单 ID?

任何帮助表示赞赏。提前致谢。

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风夜微凉 2024-12-25 22:23:04

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

<?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";
}

编辑:

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

$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";
}

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";
}

EDIT:

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";
}
梦过后 2024-12-25 22:23:04

获取订单状态为“已完成”的所有产品

$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
->addFieldToFilter('status', 'complete')
->setOrder('created_at', 'desc');

$this->setOrders($orders);
foreach ($orders as $order)
{
$order_id=$order->getRealOrderId();
$order = Mage::getModel('sales/order')->load($order_id, 'increment_id');
$order->getAllVisibleItems();
$orderItems = $order->getItemsCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('product_type', array('eq'=>'simple'))
    ->load();
foreach($orderItems as $Item)
{
    $Item = Mage::getModel('catalog/product')->setStoreId($Item->getStoreId())->load($Item->getProductId());
    if ($Item->getId())
    {
        echo $Item->getName();
        echo $Item->getPrice();
        echo $Item->getProductUrl();
        echo $Item->getImageUrl();
        }
    }
}
?>

To Get All the Products with order status as 'Completed'

$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
->addFieldToFilter('status', 'complete')
->setOrder('created_at', 'desc');

$this->setOrders($orders);
foreach ($orders as $order)
{
$order_id=$order->getRealOrderId();
$order = Mage::getModel('sales/order')->load($order_id, 'increment_id');
$order->getAllVisibleItems();
$orderItems = $order->getItemsCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('product_type', array('eq'=>'simple'))
    ->load();
foreach($orderItems as $Item)
{
    $Item = Mage::getModel('catalog/product')->setStoreId($Item->getStoreId())->load($Item->getProductId());
    if ($Item->getId())
    {
        echo $Item->getName();
        echo $Item->getPrice();
        echo $Item->getProductUrl();
        echo $Item->getImageUrl();
        }
    }
}
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文