Magento获得两个日期之间隔夜发货的所有订单号码

时间:2012-06-14 22:42:40

标签: mysql magento

标题几乎描述了它,我只需要获取所有订单号 与6-8至6-12之间的隔夜运输一起发货。

帮助表示赞赏

1 个答案:

答案 0 :(得分:1)

至少有一种实现这一目标的方法......

$from           = "2012-06-08";
$to             = "2012-06-12";
$shippingMethod = "overnight_shipping";

$orderIds = Mage::getResourceModel('sales/order_shipment_collection')
                ->addAttributeToFilter('created_at', array(
                    'from'  => $from,
                    'to'    => $to,                    
                 ))
                ->getColumnValues('order_id')
             ;

$incrementIds = Mage::getResourceModel('sales/order_collection')
                        ->addAttributeToFilter('shipping_method', array('eq' => $shippingMethod))
                        ->addAttributeToFilter('entity_id', array('in' => $orderIds))
                        ->getColumnValues('increment_id')
                ;

echo "<ul>";
foreach($incrementIds as $incrementId) {
    echo "<li>" . $incrementId . "</li>";
}
echo "</ul>";