Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取状态为“已完成”和“正在处理”的订单数_Php_Api_Magento_Mage - Fatal编程技术网

Php 获取状态为“已完成”和“正在处理”的订单数

Php 获取状态为“已完成”和“正在处理”的订单数,php,api,magento,mage,Php,Api,Magento,Mage,我使用一个Magento market segmentation插件,我不仅尝试对订单状态已完成的用户进行细分,还尝试对已完成和正在处理的用户进行细分 根据客户细分的原始代码部分如下所示: if ($this->getAttribute() == 'ordered') { $customersOrders = Mage::helper('marketsuite/customer')->getOrderCollectionByCustomerIds($_customer

我使用一个Magento market segmentation插件,我不仅尝试对订单状态已完成的用户进行细分,还尝试对已完成和正在处理的用户进行细分

根据客户细分的原始代码部分如下所示:

if ($this->getAttribute() == 'ordered') {
        $customersOrders = Mage::helper('marketsuite/customer')->getOrderCollectionByCustomerIds($_customerIds);
        $customersOrders->addFieldToFilter('state', Mage_Sales_Model_Order::STATE_COMPLETE);
        $_arrayOrderIdCustomerId = $customersOrders->getConnection()->fetchPairs($customersOrders->getSelect());
        $_arrayOrderIdTotal = $this->_getValidatedTotalOrderedCount(array_keys($_arrayOrderIdCustomerId));
        $_validatedArrayOrderIdCustomerId = array_intersect_key($_arrayOrderIdCustomerId, $_arrayOrderIdTotal);
根据订单进行细分的另一部分:

public function validateOrderCollection(Zend_Db_Select $select)
{
    if ($this->getAttribute() == 'ordered') {
        $select
            ->where('state = ?', Mage_Sales_Model_Order::STATE_COMPLETE)
        ;
        $_orderIds = Mage::helper('marketsuite/order')->getAllIds($select);
        $orderTotals = $this->_getValidatedTotalOrderedCount($_orderIds);
        $validatedOrders = array();
        foreach ($orderTotals as $orderId => $totalOrderedCount) {
            if ($this->validateAttribute($totalOrderedCount)) {
                array_push($validatedOrders, $orderId);
            }
        }
        return $validatedOrders;
    }
    return array();
}
问题:如何在这两种情况下同时包括已完成订单和正在处理的订单。我知道这与$customersOrders->addFieldToFilter'state',Mage_Sales_Model_Order::state_COMPLETE有关;但我不确定如何实现这一目标


非常感谢您的帮助。

您可以尝试以下方法:

$connection = Mage::getModel('core/resource')->getConnection('core_read');
$sql = 'SELECT `customer_id` FROM `sales_flat_order` WHERE `status` LIKE ? OR `status` LIKE ?';
$customers = $connection->fetchAll($sql, array('complete', 'processing'));
$customer = Mage::getModel('customer/customer');
foreach ($customers as $customer_info){
    $customer = $customer->load($customer_info['customer_id']);
    /* Do what you need to do here, e.g:
     * echo $customer->getName() . "<br/>";
     * This example will print all customers who have complete/processing orders full names
     */
}

你可以试试这样的

$customersOrders->addFieldToFilter('state', 
          array(
                    array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE),
                    array('eq' => Mage_Sales_Model_Order::STATE_PROCESSING),
                )
);

谢谢你的帮助,但不幸的是那没有帮助。我正在使用aheadWorks的市场细分套件。我得到的唯一提示是查看一个特定文件,从这两行开始=/谢谢你的代码,但实际上我不确定在上面发布的示例中把它放在哪里。