Mage_ProductAlert_AddController Class Reference

Inheritance diagram for Mage_ProductAlert_AddController:

Mage_Core_Controller_Front_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 preDispatch ()
 testObserverAction ()
 priceAction ()
 stockAction ()


Detailed Description

Definition at line 34 of file AddController.php.


Member Function Documentation

preDispatch (  ) 

Predispatch: shoud set layout area

Returns:
Mage_Core_Controller_Front_Action

Reimplemented from Mage_Core_Controller_Front_Action.

Definition at line 36 of file AddController.php.

00037     {
00038         parent::preDispatch();
00039 
00040         if (!Mage::getSingleton('customer/session')->authenticate($this)) {
00041             $this->setFlag('', 'no-dispatch', true);
00042             if(!Mage::getSingleton('customer/session')->getBeforeUrl()) {
00043                 Mage::getSingleton('customer/session')->setBeforeUrl($this->_getRefererUrl());
00044             }
00045         }
00046     }

priceAction (  ) 

Definition at line 55 of file AddController.php.

00056     {
00057         $session = Mage::getSingleton('catalog/session');
00058         $backUrl    = $this->getRequest()->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED);
00059         $productId  = (int) $this->getRequest()->getParam('product_id');
00060         if (!$backUrl || !$productId) {
00061             $this->_redirect('/');
00062             return ;
00063         }
00064 
00065         $product = Mage::getModel('catalog/product')->load($productId);
00066         if (!$product->getId()) {
00067             /* @var $product Mage_Catalog_Model_Product */
00068             $session->addError($this->__('Not enough parameters'));
00069             $this->_redirectUrl($backUrl);
00070             return ;
00071         }
00072 
00073         try {
00074             $model  = Mage::getModel('productalert/price')
00075                 ->setCustomerId(Mage::getSingleton('customer/session')->getId())
00076                 ->setProductId($product->getId())
00077                 ->setPrice($product->getFinalPrice())
00078                 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
00079             $model->save();
00080             $session->addSuccess($this->__('Alert subscription was saved successfully'));
00081         }
00082         catch (Exception $e) {
00083             $session->addException($e, $this->__('Please try again later'));
00084         }
00085         $this->_redirectReferer();
00086     }

stockAction (  ) 

Definition at line 88 of file AddController.php.

00089     {
00090         $session = Mage::getSingleton('catalog/session');
00091         /* @var $session Mage_Catalog_Model_Session */
00092         $backUrl    = $this->getRequest()->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED);
00093         $productId  = (int) $this->getRequest()->getParam('product_id');
00094         if (!$backUrl || !$productId) {
00095             $this->_redirect('/');
00096             return ;
00097         }
00098 
00099         if (!$product = Mage::getModel('catalog/product')->load($productId)) {
00100             /* @var $product Mage_Catalog_Model_Product */
00101             $session->addError($this->__('Not enough parameters'));
00102             $this->_redirectUrl($backUrl);
00103             return ;
00104         }
00105 
00106         try {
00107             $model = Mage::getModel('productalert/stock')
00108                 ->setCustomerId(Mage::getSingleton('customer/session')->getId())
00109                 ->setProductId($product->getId())
00110                 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
00111             $model->save();
00112             $session->addSuccess($this->__('Alert subscription was saved successfully'));
00113         }
00114         catch (Exception $e) {
00115             $session->addException($e, $this->__('Please try again later'));
00116         }
00117         $this->_redirectReferer();
00118     }

testObserverAction (  ) 

Definition at line 48 of file AddController.php.

00049     {
00050         $object = new Varien_Object();
00051         $observer = Mage::getSingleton('productalert/observer');
00052         $observer->process($object);
00053     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:34 2009 for Magento by  doxygen 1.5.8