我有我的自定义模块客户反馈/查询表格,客户可以在其中询问与产品相关的查询,或者他们可以提供与商店相关的反馈。在管理方面,我列出了管理网格中的所有反馈。
现在我想集成邮件功能,比如当我点击特定的反馈编辑部分时,邮件正文会有单独的部分,我将在其中输入回复,点击发送按钮,邮件会发送给特定客户,其中邮件 ID 已经存在那个特定的编辑部分。
这是我的AdminHtml 控制器文件的代码
<?php
class Foo_Bar_Adminhtml_BazController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
// Let's call our initAction method which will set some basic params for each action
$this->_initAction()
->renderLayout();
}
public function newAction()
{
// We just forward the new action to a blank edit form
$this->_forward('edit');
}
public function editAction()
{
$this->_initAction();
// Get id if available
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('foo_bar/baz');
if ($id) {
// Load record
$model->load($id);
// Check if record is loaded
if (!$model->getId()) {
Mage::getSingleton('adminhtml/session')->addError($this->__('This baz no longer exists.'));
$this->_redirect('*/*/');
return;
}
}
$this->_title($model->getId() ? $model->getName() : $this->__('New Baz'));
$data = Mage::getSingleton('adminhtml/session')->getBazData(true);
if (!empty($data)) {
$model->setData($data);
}
Mage::register('foo_bar', $model);
$this->_initAction()
->_addBreadcrumb($id ? $this->__('Edit Baz') : $this->__('New Baz'), $id ? $this->__('Edit Baz') : $this->__('New Baz'))
->_addContent($this->getLayout()->createBlock('foo_bar/adminhtml_baz_edit')->setData('action', $this->getUrl('*/*/save')))
->renderLayout();
}
public function saveAction()
{
if ($postData = $this->getRequest()->getPost()) {
$model = Mage::getSingleton('foo_bar/baz');
$model->setData($postData);
try {
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The baz has been saved.'));
$this->_redirect('*/*/');
return;
}
catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this baz.'));
}
Mage::getSingleton('adminhtml/session')->setBazData($postData);
$this->_redirectReferer();
}
}
public function deleteAction()
{
// check if we know what should be deleted
$itemId = $this->getRequest()->getParam('id');
if ($itemId) {
try {
// init model and delete
/** @var $model Magentostudy_News_Model_Item */
$model = Mage::getModel('foo_bar/baz');
$model->load($itemId);
if (!$model->getId()) {
Mage::throwException(Mage::helper('foo_bar')->__('Unable to find a Baz.'));
}
$model->delete();
// display success message
$this->_getSession()->addSuccess(
Mage::helper('foo_bar')->__('The Baz has been deleted.')
);
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
} catch (Exception $e) {
$this->_getSession()->addException($e,
Mage::helper('foo_bar')->__('An error occurred while deleting the baz.')
);
}
}
// go to grid
$this->_redirect('*/*/');
}
public function messageAction()
{
$data = Mage::getModel('foo_bar/baz')->load($this->getRequest()->getParam('id'));
echo $data->getContent();
}
/**
* Initialize action
*
* Here, we set the breadcrumbs and the active menu
*
* @return Mage_Adminhtml_Controller_Action
*/
protected function _initAction()
{
$this->loadLayout()
// Make the active menu match the menu config nodes (without 'children' inbetween)
->_setActiveMenu('sales/foo_bar_baz')
->_title($this->__('Sales'))->_title($this->__('Baz'))
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Baz'), $this->__('Baz'));
return $this;
}
/**
* Check currently called action by permissions for current user
*
* @return bool
*/
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('sales/foo_bar_baz');
}
}
我想要一些挂钩,我可以从中向特定客户发送邮件。这是我的管理网格部分的图像