我认为您在这里没有 Magento 版本问题。
在特定情况下,Magento 根本不允许将订单状态切换回Mage_Sales_Model_Order::STATE_PROCESSING
.
例如,通常您无法将Mage_Sales_Model_Order::STATE_PROCESSING
状态保存到任何已经退款的订单(creditmemos)。在 1.3.2.4 和 1.6.x 中都没有。
这是设计使然。
查看Magento 在哪些情况下强制将订单状态分别Mage_Sales_Model_Order::_checkState()
重置为STATE_COMPLETE
或。STATE_CLOSED
protected function _checkState()
{
if (!$this->getId()) {
return $this;
}
$userNotification = $this->hasCustomerNoteNotify() ? $this->getCustomerNoteNotify() : null;
if (!$this->isCanceled()
&& !$this->canUnhold()
&& !$this->canInvoice()
&& !$this->canShip()) {
if (0 == $this->getBaseGrandTotal() || $this->canCreditmemo()) {
if ($this->getState() !== self::STATE_COMPLETE) {
$this->_setState(self::STATE_COMPLETE, true, '', $userNotification);
}
}
/**
* Order can be closed just in case when we have refunded amount.
* In case of "0" grand total order checking ForcedCanCreditmemo flag
*/
elseif (floatval($this->getTotalRefunded()) || (!$this->getTotalRefunded()
&& $this->hasForcedCanCreditmemo())
) {
if ($this->getState() !== self::STATE_CLOSED) {
$this->_setState(self::STATE_CLOSED, true, '', $userNotification);
}
}
}
if ($this->getState() == self::STATE_NEW && $this->getIsInProcess()) {
$this->setState(self::STATE_PROCESSING, true, '', $userNotification);
}
return $this;
}
_checkState()
回答您的问题:您可以通过使用自己的方法覆盖该方法来实现您想要做的事情,该方法允许设置STATE_PROCESSING
.
但请注意,这很可能会导致创建 Magento 既不知道也不期望或无法处理的新状态上下文。
如果您的更改造成严重破坏,请不要怪我。你已经被警告了^^