Php 获取同一字段具有不同字段值的magento订单集合

Php 获取同一字段具有不同字段值的magento订单集合,php,magento,collections,Php,Magento,Collections,您好,我想为同一字段获取具有多个字段值的订单集合。我已经尝试使用addFieldToFilter为单个字段值获取集合(“状态”:打开和状态:处理),并且我将两个集合合并到一个集合中。现在我遇到了无法访问结果集合的问题,它的低谷错误像getMethod不能调用非对象。给我一些建议 这是我的密码: $shippedCollection = array(); $processingCollection = array(); $orderSCollection = Mage::getModel('sal

您好,我想为同一字段获取具有多个字段值的订单集合。我已经尝试使用addFieldToFilter为单个字段值获取集合(“状态”:打开和状态:处理),并且我将两个集合合并到一个集合中。现在我遇到了无法访问结果集合的问题,它的低谷错误像getMethod不能调用非对象。给我一些建议

这是我的密码:

$shippedCollection = array();
$processingCollection = array();
$orderSCollection = Mage::getModel('sales/order')->getCollection();
$shippedCollection = $orderSCollection->addFieldToFilter('status','delivered_carrier');
$orderPCollection = Mage::getModel('sales/order')->getCollection();
$processingCollection = $orderPCollection->addFieldToFilter('status','processing');
$order = array_merge($shippedCollection->getAllIds(),$processingCollection->getAllIds());

$order->getData('increment_id');

您好,下面的代码可能会对您有所帮助

$order_collection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('status', array('in' => array('delivered_carrier','pending')));
echo count($order_collection->getAllIds());

有一件事你必须知道:

collection !== array
您合并了数组,并且函数array_merge()还返回了一个数组,这就是您在最后一行中遇到错误的原因

下面的代码可以让您的集合通过不同的值进行过滤,并在其中循环

$ordersCollection = Mage::getModel('sales/order')->getCollection();
$filteredCollection = $ordersCollection
        ->addFieldToFilter('status', array('in' => array('pending', 'processing'))); //set statuses which you want

foreach ($filteredCollection as $order) {
    echo '<pre>'.$order->getIncrementId();
}
$ordersCollection=Mage::getModel('sales/order')->getCollection();
$filteredCollection=$ordersCollection
->addFieldToFilter('status',array('in'=>array('pending','processing'))//设置所需的状态
foreach($filteredCollection作为$order){
回显“”。$order->getIncrementId();
}
有关收藏的更多信息,请访问

希望这对你有帮助,干杯