Created
August 13, 2013 01:39
-
-
Save amacgregor/6217086 to your computer and use it in GitHub Desktop.
Original actions for the IndexController
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 newPostAction() | |
{ | |
try { | |
$data = $this->getRequest()->getParams(); | |
$registry = Mage::getModel('mdg_giftregistry/entity'); | |
$customer = Mage::getSingleton('customer/session')->getCustomer(); | |
if($this->getRequest()->getPost() && !empty($data)) { | |
$registry->updateRegistryData($customer, $data); | |
$registry->save(); | |
$successMessage = Mage::helper('mdg_giftregistry')->__('Registry Successfully Created'); | |
Mage::getSingleton('core/session')->addSuccess($successMessage); | |
}else{ | |
throw new Exception("Insufficient Data provided"); | |
} | |
} catch (Mage_Core_Exception $e) { | |
Mage::getSingleton('core/session')->addError($e->getMessage()); | |
$this->_redirect('*/*/'); | |
} | |
$this->_redirect('*/*/'); | |
} | |
public function editPostAction() | |
{ | |
try { | |
$data = $this->getRequest()->getParams(); | |
$registry = Mage::getModel('mdg_giftregistry/entity'); | |
$customer = Mage::getSingleton('customer/session')->getCustomer(); | |
if($this->getRequest()->getPosts() && !empty($data) ) | |
{ | |
$registry->load($data['registry_id']); | |
if($registry){ | |
$registry->updateRegistryData($customer, $data); | |
$registry->save(); | |
$successMessage = Mage::helper('mdg_giftregistry')->__('Registry Successfully Saved'); | |
Mage::getSingleton('core/session')->addSuccess($successMessage); | |
}else { | |
throw new Exception("Invalid Registry Specified"); | |
} | |
}else { | |
throw new Exception("Insufficient Data provided"); | |
} | |
} catch (Mage_Core_Exception $e) { | |
Mage::getSingleton('core/session')->addError($e->getMessage()); | |
$this->_redirect('*/*/'); | |
} | |
$this->_redirect('*/*/'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment