/** * @return $this */ protected function _prepareCollection() { /** @var $collection \Magento\Newsletter\Model\Resource\Queue\Collection */ $collection = $this->_collectionFactory->create()->addTemplateInfo()->addSubscriberFilter($this->_coreRegistry->registry('subscriber')->getId()); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * Return queue collection with loaded neversent queues * * @return Collection */ public function getQueueCollection() { if (is_null($this->_queueCollection)) { /** @var $this->_queueCollection \Magento\Newsletter\Model\Resource\Queue\Collection */ $this->_queueCollection = $this->_collectionFactory->create()->addTemplateInfo()->addOnlyUnsentFilter()->load(); } return $this->_queueCollection; }
/** * Scheduled send handler * * @param Schedule $schedule * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function scheduledSend($schedule) { $countOfQueue = 3; $countOfSubscriptions = 20; /** @var \Magento\Newsletter\Model\Resource\Queue\Collection $collection */ $collection = $this->_queueCollectionFactory->create(); $collection->setPageSize($countOfQueue)->setCurPage(1)->addOnlyForSendingFilter()->load(); $collection->walk('sendPerSubscriber', [$countOfSubscriptions]); }