/** * Check usage of template code in other templates * * @param \Magento\Email\Model\Template $template * @return bool */ public function checkCodeUsage(\Magento\Email\Model\Template $template) { if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) { $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), 'COUNT(*)')->where('template_code = :template_code'); $bind = array('template_code' => $template->getTemplateCode()); $templateId = $template->getId(); if ($templateId) { $select->where('template_id != :template_id'); $bind['template_id'] = $templateId; } $result = $this->_getReadAdapter()->fetchOne($select, $bind); if ($result) { return true; } } return false; }