Example #1
0
 public function getContent()
 {
     $content = $this->getRecipient()->getContent();
     $store = $this->getRecipient()->getStore();
     if ($this->allowPrerender()) {
         $cacheId = self::PRERENDER_CACHE_PREFIX . $content->getContentCacheId();
         $data = Mage::app()->loadCache($cacheId);
         if ($data) {
             $data = unserialize($data);
         }
         if (!$data) {
             $storeId = $this->getRecipient()->getStoreId();
             /* @var $processor Mzax_Emarketing_Model_Medium_Email_Processor */
             $processor = Mage::getModel('mzax_emarketing/medium_email_processor');
             $processor->disableVarDirective(true);
             $processor->setStoreId($storeId);
             $processor->setContent($content);
             $processor->setVariables(array('current_year' => date('Y'), 'date' => Mage::app()->getLocale()->storeDate($store), 'store' => $this->getRecipient()->getCampaign()->getStore()));
             $this->emulateDesign($storeId);
             $subject = $processor->getSubject();
             $bodyHtml = $processor->getBodyHtml();
             $bodyText = $processor->getBodyText();
             $this->revertDesign();
             if (Mage::getStoreConfigFlag('mzax_emarketing/email/css_inliner', $storeId)) {
                 $this->inlineCss($bodyHtml);
             }
             if (Mage::getStoreConfigFlag('mzax_emarketing/email/remove_comments', $storeId)) {
                 $this->removeComments($bodyHtml);
             }
             $data = new Varien_Object();
             $data->setSubject($subject);
             $data->setBodyHtml($bodyHtml);
             $data->setBodyText($bodyText);
             Mage::app()->saveCache(serialize($data), $cacheId, array(Mzax_Emarketing_Model_Campaign::CACHE_TAG));
         }
         /* @var $fullCache Mzax_Emarketing_Model_Medium_Email_FullCache */
         $fullCache = Mage::getModel('mzax_emarketing/medium_email_fullCache');
         $fullCache->setMediumData($data);
         return $fullCache;
     }
     return $content;
 }