/** * Set the order status history object and the order object to each other * Adds the object to the status history collection, which is automatically saved when the order is saved. * See the entity_id attribute backend model. * Or the history record can be saved standalone after this. * * @param \Magento\Sales\Model\Order\Status\History $history * @return $this */ public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $history) { $history->setOrder($this); $this->setStatus($history->getStatus()); if (!$history->getId()) { $this->setStatusHistories(array_merge($this->getStatusHistories(), [$history])); $this->setDataChanges(true); } return $this; }
/** * Set the order status history object and the order object to each other * Adds the object to the status history collection, which is automatically saved when the order is saved. * See the entity_id attribute backend model. * Or the history record can be saved standalone after this. * * @param \Magento\Sales\Model\Order\Status\History $history * @return $this */ public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $history) { $history->setOrder($this); $this->setStatus($history->getStatus()); if (!$history->getId()) { $this->getStatusHistoryCollection()->addItem($history); $this->setDataChanges(true); } return $this; }