Exemple #1
0
 public function prepareRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     $customer = Mage::getModel('customer/customer')->load($recipient->getObjectId());
     $recipient->setCustomer($customer);
     $recipient->setEmail($customer->getEmail());
     $recipient->setName($customer->getName());
 }
Exemple #2
0
 public function prepareRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     /* @var $order Mage_Sales_Model_Order */
     $order = Mage::getModel('sales/order')->load($recipient->getObjectId());
     $recipient->setOrder($order);
     $recipient->setCustomer($order->getCustomer());
     $recipient->setEmail($order->getCustomerEmail());
     $recipient->setName($order->getCustomerName());
 }
Exemple #3
0
 /**
  * Set recipient
  *
  * @param Mzax_Emarketing_Model_Recipient $recipient
  * @return Mzax_Emarketing_Model_Recipient_Bounce_Message
  */
 public function setRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     $this->_recipient = $recipient;
     if ($this->_campaign) {
         $this->_recipient->setCampaign($this->_campaign);
     } else {
         $this->_campaign = $recipient->getCampaign();
     }
     return $this;
 }
Exemple #4
0
 public function prepareRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     /* @var $quote Mage_Sales_Model_Quote */
     $quote = Mage::getModel('sales/quote')->load($recipient->getObjectId());
     $recipient->setQuote($quote);
     $recipient->setCustomer($quote->getCustomer());
     $recipient->setEmail($quote->getCustomerEmail());
     $recipient->setName($quote->getCustomerName());
 }
Exemple #5
0
 /**
  * Insert tracking beacon
  * allows to see if an email is viewed or not
  *
  * @return string
  */
 public function insertBeacon(&$html)
 {
     $beaconHtml = "<img alt=\"{$this->_recipient->getCampaign()->getStore()->getName()}\" src=\"{$this->getBeaconImage()}\" style=\"width:10px; height:5px;\" />";
     // if beacon placeholder exist replace it
     if (strpos($html, self::BEACON_PLACEHOLDER) !== false) {
         $html = str_replace(self::BEACON_PLACEHOLDER, $beaconHtml, $html);
     } else {
         if (strpos($html, "</body>") !== false) {
             $html = str_replace("</body>", "{$beaconHtml}\n</body>", $html);
         } else {
             $html .= $beaconHtml;
         }
     }
     return $this;
 }
Exemple #6
0
 /**
  * Send email to recipient
  * 
  * Note: The email medium is not responsible for sending out the email directly
  * it will prepare the recipient and the email and push the email to the Outbox
  * model, which then will send out the emails
  * 
  * @param Mzax_Emarketing_Model_Recipient $recipient
  * @throws Exception
  */
 public function sendRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     $recipient->prepare();
     if (!$recipient->getAddress()) {
         throw new Exception("No address set");
     }
     /* @var $email Mzax_Emarketing_Model_Outbox_Email */
     $email = Mage::getModel('mzax_emarketing/outbox_email');
     $email->setTo($recipient->getAddress());
     $email->setRecipient($recipient);
     $email->render();
     $email->setExpireAt($recipient->getExpireAt());
     if (!$recipient->isMock()) {
         $data = $recipient->getContent()->getMediumData();
         $dayFilter = $data->getDayFilter();
         $timeFilter = $data->getTimeFilter();
         // apply day filter
         if (is_array($dayFilter) && count($dayFilter) && count($dayFilter) < 7) {
             $email->setDayFilter(implode(',', $dayFilter));
         }
         // apply time filter
         if (is_array($timeFilter) && count($timeFilter) && count($timeFilter) < 24) {
             $email->setTimeFilter(implode(',', $timeFilter));
         }
     }
     $email->save();
     // if mock, send out email straight away
     if ($recipient->isMock() && !$recipient->getSkipSend()) {
         $email->send();
     }
 }
Exemple #7
0
 /**
  * Set recipient model
  * 
  * @param Mzax_Emarketing_Model_Recipient $recipient
  * @return Mzax_Emarketing_Model_Link
  */
 public function setRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     $this->_recipient = $recipient;
     $this->setRecipientId($recipient->getId());
     return $this;
 }
Exemple #8
0
 /**
  * Prepare recipient for sending
  * this should at least set email and name to the recipient
  * but can also set any other data that later can be used
  * inside the templates
  *
  * @param Mzax_Emarketing_Model_Recipient $recipient
  */
 public function prepareRecipient(Mzax_Emarketing_Model_Recipient $recipient)
 {
     $object = Mage::getModel($this->_entityId);
     $object->load($recipient->getObjectId());
     $recipient->setObject($object);
 }