Beispiel #1
0
 /**
  * @param string       $key
  * @param string|array $value
  * @param string       $type
  *
  * @return Bronto_Common_Model_Email_Template_Filter
  */
 public function setField($key, $value, $type = 'html')
 {
     if (!is_string($key) || empty($key)) {
         return $this;
     }
     if (is_array($value)) {
         // Address objects come in as an array on payment failed emails
         $delim = $type == 'html' ? '<br/>' : "\n\r";
         if (isset($value['address_id'])) {
             $new_value = $value['street'] . $delim;
             $new_value .= $value['city'] . $delim;
             $new_value .= $value['region'] . $delim;
             $new_value .= $value['postcode'] . $delim;
             $new_value .= $value['country_id'];
             $this->_delivery->setField($key, $new_value, $type);
         }
     } else {
         if (isset($this->_prettyMap[$key])) {
             // Overwrite $key if we have a mapped overridden value
             $key = $this->_prettyMap[$key];
         }
         $this->_delivery->setField($key, $value, $type);
     }
     return $this;
 }
Beispiel #2
0
 /**
  * Log data on sending message
  *
  * @param bool                    $success
  * @param string                  $error
  * @param Bronto_Api_Delivery_Row $delivery
  *
  * @return void
  */
 protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
 {
     Mage::dispatchEvent('bronto_email_send_after');
     if (Mage::helper('bronto_email')->isLogEnabled()) {
         $this->_log->setSuccess((int) $success);
         if (!empty($error)) {
             $this->_log->setError($error);
         }
         if ($delivery) {
             $this->_log->setDeliveryId($delivery->id);
             if (Mage::helper('bronto_email')->isLogFieldsEnabled()) {
                 $this->_log->setFields(serialize($delivery->getFields()));
             }
         }
         $this->_log->save();
         $this->_log = null;
     }
 }
Beispiel #3
0
 /**
  * Sets an array of products, representing related products
  * in a delivery as relatedXxx_# API fields
  *
  * @param Bronto_Api_Delivery_Row $delivery
  * @param array $productHash
  * @param int $storeId
  * @return void
  */
 public function setRelatedFields($delivery, $productHash, $storeId = null)
 {
     $currentData = $delivery->hasFields() ? $delivery->getFields() : array();
     foreach ($this->relatedFields($productHash, $storeId) as $fields) {
         $currentData = array_merge($currentData, $fields);
     }
     // By passing the setField call on the API is far more efficient
     $delivery->withFields($currentData);
 }
 /**
  * Allows the retryer to trigger
  *
  * @param Bronto_Api_Delivery $deliveryObject
  */
 public function triggerBeforeAfterSend(Bronto_Api_Delivery_Row $delivery)
 {
     $contactObject = $delivery->getApi()->getContactObject();
     $messageObject = $delivery->getApi()->getMessageObject();
     $contact = $contactObject->createRow();
     $message = $messageObject->createRow();
     $message->id = $delivery->messageId;
     $contact->id = $delivery->recipients[0]['id'];
     try {
         $message->read();
         $contact->read();
         $this->_beforeSend($contact, $message);
         $this->_afterSend(true, null, $delivery);
     } catch (Exception $e) {
         Mage::helper('bronto_common')->writeError('Failed to trigger email send: ' . $e->getMessage());
     }
 }
Beispiel #5
0
 /**
  * Sets an array of products, representing related products
  * in a delivery as relatedXxx_# API fields
  *
  * @param Bronto_Api_Delivery_Row $delivery
  * @param array $productHash
  * @param int $storeId
  * @return void
  */
 public function setRelatedFields($delivery, $productHash, $storeId = null)
 {
     $currentData = $delivery->getData();
     if (empty($currentData['fields'])) {
         $currentData['fields'] = array();
     }
     foreach ($this->relatedFields($productHash, $storeId) as $fields) {
         $currentData['fields'] = array_merge($currentData['fields'], $fields);
     }
     // By passing the setField call on the API is far more efficient
     $delivery->setData($currentData);
 }