我们已经在我们的网店中构建了一个自定义 Magento 模块,用于联系查询。
请参阅下面的 IndexController。我们想更改每个商店视图的重定向路线。我们怎样才能做到这一点?
<?php
class MVE_ContactInquiry_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'mve.contact_inquiry',
array(
'template' => 'mve/contact_inquiry.phtml'
)
);
$this->getLayout()->getBlock('content')->append($block);
//$this->getLayout()->getBlock('right')->insert($block, 'catalog.compare.sidebar', true);
$this->_initLayoutMessages('core/session');
$this->renderLayout();
}
public function sendemailAction()
{
$params = $this->getRequest()->getParams();
$mail = new Zend_Mail();
$bodytext = '
Naam: ' . $params['name'] . '
E-mailadres: ' . $params['email'] . '
Telefoonnummer: ' . $params['telephone'] . '
Bericht:
' . $params['comment'];
$mail->setBodyText( $bodytext );
$mail->setFrom($params['email'], $params['name']);
$mail->addTo('example@gmail.com');
$mail->setSubject('Contact aanvraag');
try {
$mail->send();
}
catch(Exception $ex) {
Mage::getSingleton('core/session')->addError('Unable to send email.');
}
$this->_redirect('contact/bedankt');
}
}
?>