Ejemplo n.º 1
0
 /**
  * Updates data when subscriber received
  *
  * @param \Magento\Newsletter\Model\Subscriber $subscriber
  * @param \Magento\Newsletter\Model\Queue $queue
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue)
 {
     $this->connection->beginTransaction();
     try {
         $data['letter_sent_at'] = $this->_date->gmtDate();
         $this->connection->update($this->_subscriberLinkTable, $data, ['subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()]);
         $this->connection->commit();
     } catch (\Exception $e) {
         $this->connection->rollBack();
         throw new \Magento\Framework\Exception\LocalizedException(__('We cannot mark as received subscriber.'));
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Add Queue Data
  *
  * @param \Magento\Newsletter\Model\Queue $queue
  * @return $this
  */
 public function addQueueData(\Magento\Newsletter\Model\Queue $queue)
 {
     $this->setQueueId($queue->getId());
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Returns queue linked stores
  *
  * @param ModelQueue $queue
  * @return array
  */
 public function getStores(ModelQueue $queue)
 {
     $adapter = $this->_getReadAdapter();
     $select = $adapter->select()->from($this->getTable('newsletter_queue_store_link'), 'store_id')->where('queue_id = :queue_id');
     if (!($result = $adapter->fetchCol($select, array('queue_id' => $queue->getId())))) {
         $result = array();
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Set loading mode subscribers by queue
  *
  * @param ModelQueue $queue
  * @return $this
  */
 public function useQueue(ModelQueue $queue)
 {
     $this->getSelect()->join(array('link' => $this->_queueLinkTable), "link.subscriber_id = main_table.subscriber_id", array())->where("link.queue_id = ? ", $queue->getId());
     $this->_queueJoinedFlag = true;
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Returns queue linked stores
  *
  * @param ModelQueue $queue
  * @return array
  */
 public function getStores(ModelQueue $queue)
 {
     $connection = $this->getConnection();
     $select = $connection->select()->from($this->getTable('newsletter_queue_store_link'), 'store_id')->where('queue_id = :queue_id');
     if (!($result = $connection->fetchCol($select, ['queue_id' => $queue->getId()]))) {
         $result = [];
     }
     return $result;
 }