56 private $paymentFailures;
88 ->get(\
Magento\Sales\Api\PaymentFailuresInterface::class);
99 $order = $this->orderRepository->get(
$id);
100 if (
$order->canCancel()) {
102 $this->orderRepository->save(
$order);
117 $this->criteriaBuilder->addFilters(
118 [$this->filterBuilder->setField(
'parent_id')->setValue(
$id)->setConditionType(
'eq')->create()]
133 $order = $this->orderRepository->get(
$id);
134 $order->addStatusHistory($statusHistory);
135 $this->orderRepository->save(
$order);
136 $notify = isset($statusHistory[
'is_customer_notified']) ? $statusHistory[
'is_customer_notified'] :
false;
137 $comment = trim(strip_tags($statusHistory->getComment()));
138 $this->orderCommentSender->send(
$order, $notify, $comment);
150 $order = $this->orderRepository->get(
$id);
151 return $this->notifier->notify(
$order);
162 return $this->orderRepository->get(
$id)->getStatus();
173 $order = $this->orderRepository->get(
$id);
175 return (
bool)$this->orderRepository->save(
$order);
186 $object = $this->orderRepository->get(
$id);
188 return (
bool)$this->orderRepository->save($object);
202 return $this->orderRepository->save(
$order);
206 $this->paymentFailures->handle((
int)
$order->getQuoteId(),
__($e->getMessage()));
235 $isCustomerNotified =
null,
236 $shouldProtectState =
true 239 if ($shouldProtectState) {
240 if (
$order->isStateProtected($state)) {
241 throw new \Magento\Framework\Exception\LocalizedException(
242 __(
'The Order State "%1" must not be set manually.', $state)
247 $transport = new \Magento\Framework\DataObject(
251 'comment' => $comment,
252 'is_customer_notified' => $isCustomerNotified
256 $this->eventManager->dispatch(
257 'sales_order_state_change_before',
258 [
'order' => $this,
'transport' => $transport]
260 $status = $transport->getStatus();
261 $order->setData(
'state', $transport->getState());
266 $status =
$order->getConfig()->getStateDefaultStatus($transport->getState());
269 $history =
$order->addStatusHistoryComment($transport->getComment(),
false);
271 $history->setIsCustomerNotified($transport->getIsCustomerNotified());
__construct(\Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Sales\Api\OrderStatusHistoryRepositoryInterface $historyRepository, \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, \Magento\Sales\Model\OrderNotifier $notifier, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender $orderCommentSender, \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures=null)
place(\Magento\Sales\Api\Data\OrderInterface $order)
addComment($id, \Magento\Sales\Api\Data\OrderStatusHistoryInterface $statusHistory)
setState(\Magento\Sales\Api\Data\OrderInterface $order, $state, $status=false, $comment='', $isCustomerNotified=null, $shouldProtectState=true)