由于不推荐使用load()和save()(因为:)
* @deprecated 100.1.0 because entities must not be responsible for their own loading.
* Service contracts should persist entities. Use resource model "load" or collections to implement
* service contract model loading operations.
我使用OrderRepositoryInterface加载和保存订单:
use Magento\Sales\Api\OrderRepositoryInterface;
public function __construct(
OrderRepositoryInterface $orderRepository,
...
) {
$this->orderRepository = $orderRepository;
}
...
$order = $this->orderRepository->get($orderId);
$order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);
$order->setStatus(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);
try {
$this->orderRepository->save($order);
} catch (\Exception $e) {
$this->logger->error($e);
$this->messageManager->addExceptionMessage($e, $e->getMessage());
}
希望能帮助到你