Exemple #1
0
 public function testGetStores()
 {
     $stores = ['store'];
     $this->resource->expects($this->once())->method('getStores')->willReturn($stores);
     $this->assertEquals($stores, $this->queue->getStores());
 }
Exemple #2
0
 /**
  * Links queue to store
  *
  * @param ModelQueue $queue
  * @return $this
  */
 public function setStores(ModelQueue $queue)
 {
     $adapter = $this->_getWriteAdapter();
     $adapter->delete($this->getTable('newsletter_queue_store_link'), array('queue_id = ?' => $queue->getId()));
     $stores = $queue->getStores();
     if (!is_array($stores)) {
         $stores = array();
     }
     foreach ($stores as $storeId) {
         $data = array();
         $data['store_id'] = $storeId;
         $data['queue_id'] = $queue->getId();
         $adapter->insert($this->getTable('newsletter_queue_store_link'), $data);
     }
     $this->removeSubscribersFromQueue($queue);
     if (count($stores) == 0) {
         return $this;
     }
     $subscribers = $this->_subscriberCollection->addFieldToFilter('store_id', array('in' => $stores))->useOnlySubscribed()->load();
     $subscriberIds = array();
     foreach ($subscribers as $subscriber) {
         $subscriberIds[] = $subscriber->getId();
     }
     if (count($subscriberIds) > 0) {
         $this->addSubscribersToQueue($queue, $subscriberIds);
     }
     return $this;
 }