出于调试目的,我需要将某些订单的状态更改为处理后,之后它们已经发货,因此状态已完成。
我正在尝试以编程方式执行此操作,因此我删除了订单的装运以及发票,但我无法强迫状态重新处理并保持完整。
是否可以这样做,或者一旦状态完成,就无法返回状态流?
只是代码的片段:
protected function deleteShipments(){
foreach($this->_ordersToProcess as $incrementId){
$myOrder = $this->_order->loadByIncrementId($incrementId);
if($this->_registry->registry('isSecureArea')){
$this->_registry->unregister('isSecureArea');
}
$this->_registry->register('isSecureArea', true);
$_shipments = $myOrder->getShipmentsCollection();
if($_shipments){
foreach($_shipments as $_shipment){
$_shipment->delete();
}
}
$_invoices = $myOrder->getInvoiceCollection();
if($_invoices){
foreach($_invoices as $invoice){
$invoice->delete();
}
}
$myOrder->setState(MagentoSalesModelOrder::STATE_PROCESSING, true)->setStatus(MagentoSalesModelOrder::STATE_PROCESSING, true);
$myOrder->save();
}
}
订单状态无法在管理面板中更改,因为它会破坏Magento本身的业务逻辑。通常,只有可以取消,持有和禁止待处理的订单。如果您想取消具有"处理"状态或"完整"状态的订单,则必须为此创建信用说明。
有关更多信息,您可以在此处查看https://www.mag-manager.com/useful-articles/magento-orders-management/magento-change-order-status-status-status-tatus-to-to-yany-from-yan/te/p>