Exemplo n.º 1
0
 /**
  * Notify user
  *
  * @param AbstractModel $model
  * @return bool
  * @throws \Magento\Framework\Exception\MailException
  */
 public function notify(\Magento\Sales\Model\AbstractModel $model)
 {
     try {
         $this->sender->send($model);
         if (!$model->getEmailSent()) {
             return false;
         }
         $historyItem = $this->historyCollectionFactory->create()->getUnnotifiedForInstance($model);
         if ($historyItem) {
             $historyItem->setIsCustomerNotified(1);
             $historyItem->save();
         }
     } catch (\Magento\Framework\Exception\MailException $e) {
         $this->logger->critical($e);
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Return collection of order status history items.
  *
  * @return HistoryCollection
  */
 public function getStatusHistoryCollection()
 {
     $collection = $this->_historyCollectionFactory->create()->setOrderFilter($this)
         ->setOrder('created_at', 'desc')
         ->setOrder('entity_id', 'desc');
     if ($this->getId()) {
         foreach ($collection as $status) {
             $status->setOrder($this);
         }
     }
     return $collection;
 }