Magento订单状态迷思
01 | require_once ( 'app/Mage.php' ); |
05 | $order = Mage::getModel( 'sales/order' ); |
06 | $order ->loadByIncrementId(100000001); |
09 | $status = $order ->getStatus(); |
10 | $state = $order ->getState(); |
17 | $order ->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING); |
订单有两个状态变量:state和status,这让人困惑,只有测试下了,于是下了个单,然后在Magneto后台处理订单,得出下面的状态值。
在Magento代码文件app\code\core\Mage\Sales\Model\Order.php中定义了订单的状态常量:
13 | class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract |
19 | const STATE_NEW = 'new' ; |
20 | const STATE_PENDING_PAYMENT = 'pending_payment' ; |
21 | const STATE_PROCESSING = 'processing' ; |
22 | const STATE_COMPLETE = 'complete' ; |
23 | const STATE_CLOSED = 'closed' ; |
24 | const STATE_CANCELED = 'canceled' ; |
25 | const STATE_HOLDED = 'holded' ; |
26 | const STATE_PAYMENT_REVIEW = 'payment_review' ; |
31 | const ACTION_FLAG_CANCEL = 'cancel' ; |
32 | const ACTION_FLAG_HOLD = 'hold' ; |
33 | const ACTION_FLAG_UNHOLD = 'unhold' ; |
34 | const ACTION_FLAG_EDIT = 'edit' ; |
35 | const ACTION_FLAG_CREDITMEMO= 'creditmemo' ; |
36 | const ACTION_FLAG_INVOICE = 'invoice' ; |
37 | const ACTION_FLAG_REORDER = 'reorder' ; |
38 | const ACTION_FLAG_SHIP = 'ship' ; |
39 | const ACTION_FLAG_COMMENT = 'comment' ; |
43 | </core@magentocommerce.com> |
其中,pending_payment, payment_review 没有测试到,后来发现是支付(Paypal, Amazon Pay)过程中引入的状态。具体请看 Magento orders: states and statuses,文章阐述了Order States and Order Statuses的区别, 还有如何在Magento订单中增加自定义状态。