Last active
December 21, 2015 16:48
-
-
Save amacgregor/6335746 to your computer and use it in GitHub Desktop.
Added the new save action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
public function saveAction() | |
{ | |
if ($data = $this->getRequest()->getPost()) { | |
try { | |
$model = $this->_initModel(); | |
if($model === false) | |
{ | |
throw new Exception("There was a problem saving the registry"); | |
} | |
$customer = Mage::getSingleton('customer/session')->getCustomer(); | |
// Update the model with the form data | |
$model->updateRegistryData($customer, $data); | |
$model->save(); | |
Mage::getSingleton('core/session') | |
->addSuccess($this->__('The gift registry has been saved.')); | |
if ($redirectBack = $this->getRequest()->getParam('back', false)) { | |
$this->_redirect('*/*/edit', array('id' => $model->getId(), 'store' => $model->getStoreId())); | |
return; | |
} | |
} catch (Mage_Core_Exception $e) { | |
Mage::logException($e); | |
Mage::getSingleton('core/session')->addError($e->getMessage()); | |
$this->_redirect('*/*/edit', array('id' => $model->getId())); | |
return; | |
} catch (Exception $e) { | |
Mage::getSingleton('core/session')->addError($this->__('There was an error trying to save the gift registry.')); | |
Mage::logException($e); | |
} | |
} | |
$this->_redirect('*/*/'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment