Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Last active December 21, 2015 16:48
Show Gist options
  • Save amacgregor/6335746 to your computer and use it in GitHub Desktop.
Save amacgregor/6335746 to your computer and use it in GitHub Desktop.
Added the new save action
<?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