Public Member Functions | |
getSubscribersCollection () | |
addTemplateData ($data) | |
sendPerSubscriber ($count=20, array $additionalVariables=array()) | |
getDataForSave () | |
addSubscribersToQueue (array $subscriberIds) | |
setSaveTemplateFlag ($value) | |
getSaveTemplateFlag () | |
setSaveStoresFlag ($value) | |
getSaveStoresFlag () | |
setStores (array $storesIds) | |
getStores () | |
getTemplate () | |
Public Attributes | |
const | STATUS_NEVER = 0 |
const | STATUS_SENDING = 1 |
const | STATUS_CANCEL = 2 |
const | STATUS_SENT = 3 |
const | STATUS_PAUSE = 4 |
Protected Member Functions | |
_construct () | |
Protected Attributes | |
$_template | |
$_subscribersCollection = null | |
$_saveTemplateFlag = false | |
$_saveStoresFlag = false | |
$_stores = false |
Definition at line 34 of file Queue.php.
_construct | ( | ) | [protected] |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 62 of file Queue.php.
00063 { 00064 $this->_init('newsletter/queue'); 00065 }
addSubscribersToQueue | ( | array $ | subscriberIds | ) |
Definition at line 150 of file Queue.php.
00151 { 00152 $this->_getResource()->addSubscribersToQueue($this, $subscriberIds); 00153 return $this; 00154 }
addTemplateData | ( | $ | data | ) |
Add template data to queue.
Varien_Object | $data |
Definition at line 89 of file Queue.php.
00090 { 00091 $template = $this->getTemplate(); 00092 if ($data->getTemplateId() && $data->getTemplateId() != $template->getId()) { 00093 $template->load($data->getTemplateId()); 00094 } 00095 00096 return $this; 00097 }
getDataForSave | ( | ) |
Definition at line 141 of file Queue.php.
00141 { 00142 $data = array(); 00143 $data['template_id'] = $this->getTemplateId(); 00144 $data['queue_status'] = $this->getQueueStatus(); 00145 $data['queue_start_at'] = $this->getQueueStartAt(); 00146 $data['queue_finish_at'] = $this->getQueueFinishAt(); 00147 return $data; 00148 }
getSaveStoresFlag | ( | ) |
getSaveTemplateFlag | ( | ) |
getStores | ( | ) |
Definition at line 185 of file Queue.php.
00186 { 00187 if(!$this->_stores) { 00188 $this->_stores = $this->_getResource()->getStores($this); 00189 } 00190 00191 return $this->_stores; 00192 }
getSubscribersCollection | ( | ) |
Returns subscribers collection for this queue
Definition at line 72 of file Queue.php.
00073 { 00074 if (is_null($this->_subscribersCollection)) { 00075 $this->_subscribersCollection = Mage::getResourceModel('newsletter/subscriber_collection') 00076 ->useQueue($this); 00077 } 00078 00079 return $this->_subscribersCollection; 00080 }
getTemplate | ( | ) |
Retrieve Newsletter Template object
Definition at line 199 of file Queue.php.
00200 { 00201 if (is_null($this->_template)) { 00202 $this->_template = Mage::getModel('newsletter/template') 00203 ->load($this->getTemplateId()); 00204 } 00205 return $this->_template; 00206 }
Send messages to subscribers for this queue
int | $count | |
array | $additionalVariables |
Definition at line 105 of file Queue.php.
00106 { 00107 if($this->getQueueStatus()!=self::STATUS_SENDING && ($this->getQueueStatus()!=self::STATUS_NEVER && $this->getQueueStartAt()) ) { 00108 return $this; 00109 } 00110 00111 if($this->getSubscribersCollection()->getSize()==0) { 00112 return $this; 00113 } 00114 00115 $collection = $this->getSubscribersCollection() 00116 ->useOnlyUnsent() 00117 ->showCustomerInfo() 00118 ->setPageSize($count) 00119 ->setCurPage(1) 00120 ->load(); 00121 00122 if(!$this->getTemplate()) { 00123 $this->addTemplateData($this); 00124 if(!$this->getTemplate()->isPreprocessed()) { 00125 $this->getTemplate()->preproccess(); 00126 } 00127 } 00128 00129 foreach($collection->getItems() as $item) { 00130 $this->getTemplate()->send($item, array('subscriber'=>$item), null, $this); 00131 } 00132 00133 if(count($collection->getItems()) < $count-1 || count($collection->getItems()) == 0) { 00134 $this->setQueueFinishAt(now()); 00135 $this->setQueueStatus(self::STATUS_SENT); 00136 $this->save(); 00137 } 00138 return $this; 00139 }
setSaveStoresFlag | ( | $ | value | ) |
setSaveTemplateFlag | ( | $ | value | ) |
setStores | ( | array $ | storesIds | ) |
Definition at line 178 of file Queue.php.
00179 { 00180 $this->setSaveStoresFlag(true); 00181 $this->_stores = $storesIds; 00182 return $this; 00183 }
const STATUS_CANCEL = 2 |
const STATUS_NEVER = 0 |
const STATUS_PAUSE = 4 |
const STATUS_SENDING = 1 |
const STATUS_SENT = 3 |