I'm working on Magento 1.7 (I know - in process of upgrading to 2) and made a custom form as a Magento plugin. Everything upto the redirect works - but I'm not sure why or how to debug.

This is my sendEmail() function:

$mail = Mage::getModel('core/email');

$mail->setFromName('MPW Site');
$mail->setSubject('Thank You For Registering Your Atom Battery');

try {
    Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
    $this->_redirect('custom-page-?code='. $code);
} catch (Exception $e) {
    Mage::getSingleton('core/session')->addError('Unable to send');

However, this snippet results in a White Screen of Death - so I put this in my index.php file to try and debug:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

function fatal_handler() {
    $error = error_get_last();

but still - nothing on screen. var/log also hasn't got any files with a last edit timestamp of today on so I'm really not sure how/why the code is going askew. From what I read online, that redirect should work.

How do I redirect to a CMS page after my form submits?


I found a solution.

$this->_redirect() is a method only available to classes extending Mage_Core_Controller_Front_Action - the code I had lived inside a Block class. Hence no access to $this->_redirect().

Still weird how the debug function and logging didn't pick up on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.