/**
  * Check usage of template code in other templates
  *
  * @param   Mage_Core_Model_Email_Template $template
  * @return  boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_read->select()->from($this->_templateTable, new Zend_Db_Expr('COUNT(template_id)'))->where('template_id!=?', $template->getId())->where('template_code=?', $template->getTemplateCode());
         $countOfCodes = $this->_read->fetchOne($select);
         return $countOfCodes > 0;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Check usage of template code in other templates
  *
  * @param Mage_Core_Model_Email_Template $template
  * @return boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), 'COUNT(*)')->where('template_id != :template_id')->where('template_code = :template_code');
         $bind = array('template_id' => $template->getId(), 'template_code' => $template->getTemplateCode());
         $result = $this->_getReadAdapter()->fetchOne($select, $bind);
         if ($result) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function testSendTransactional()
 {
     $this->_model->sendTransactional('customer_create_account_email_template', array('name' => 'Sender Name', 'email' => '*****@*****.**'), '*****@*****.**', 'Recipient Name');
     $this->assertEquals('customer_create_account_email_template', $this->_model->getId());
     $this->assertTrue($this->_model->getSentSuccess());
 }
Exemplo n.º 4
0
 public function addTemplateToConfig(Mage_Core_Model_Email_Template $template, $templateCode = '', $scope = '', $scopeId = null)
 {
     if (!$templateCode) {
         $templateCode = Mage::app()->getRequest()->getParam('templatecode');
     }
     try {
         if (is_null($scopeId)) {
             list($scope, $scopeId) = $this->_getCurrentScope();
         }
         $oReq = Mage::app()->getFrontController()->getRequest();
         if ($scope) {
             $templatePath = Mage::helper('aitemails')->getPathByEmailTemplateCode($templateCode);
             if ($templatePath) {
                 Mage::getConfig()->saveConfig($templatePath, $template->getId(), $scope, $scopeId);
                 Mage::getConfig()->reinit();
                 Mage::app()->reinitStores();
                 //$this->_getRulerResource()->markConfig($configDataModel);
             }
         }
     } catch (Exception $exc) {
     }
 }