public function delete(Mage_Core_Model_Abstract $template) { $templateId = $template->getId(); // removing attachments $attachmentCollection = Mage::getModel('aitemails/aitattachment')->getTemplateAttachments($templateId); if (count($attachmentCollection) > 0) { foreach ($attachmentCollection as $attachment) { @unlink(Aitoc_Aitemails_Model_Aitattachment::getBasePath() . $attachment->getAttachmentFile()); @unlink(Aitoc_Aitemails_Model_Aitattachment::getBaseTmpPath() . $attachment->getAttachmentFile()); Mage::getModel('aitemails/aitattachment')->load($attachment->getId())->delete(); } } return parent::delete($template); }
/** * Initialize email template resource model * */ protected function _construct() { parent::_construct(); $this->_init('bronto_email/template', 'template_id'); $this->_setMainTable('core/email_template', 'template_id'); }