/**
  * 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;
 }