/**
  * Handles asynchronous email sending
  * @return void
  */
 public function sendEmails()
 {
     if ($this->globalConfig->getValue('sales_email/general/async_sending')) {
         $this->entityCollection->addFieldToFilter('send_email', ['eq' => 1]);
         $this->entityCollection->addFieldToFilter('email_sent', ['null' => true]);
         /** @var \Magento\Sales\Model\AbstractModel $item */
         foreach ($this->entityCollection->getItems() as $item) {
             if ($this->emailSender->send($item, true)) {
                 $this->entityResource->save($item->setEmailSent(true));
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function save(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order $object */
     $this->stateHandler->check($object);
     return parent::save($object);
 }