Public Member Functions | |
preDispatch () | |
priceAction () | |
priceAllAction () | |
stockAction () | |
stockAllAction () |
Definition at line 35 of file UnsubscribeController.php.
preDispatch | ( | ) |
Predispatch: shoud set layout area
Reimplemented from Mage_Core_Controller_Front_Action.
Definition at line 37 of file UnsubscribeController.php.
00038 { 00039 parent::preDispatch(); 00040 00041 if (!Mage::getSingleton('customer/session')->authenticate($this)) { 00042 $this->setFlag('', 'no-dispatch', true); 00043 if(!Mage::getSingleton('customer/session')->getBeforeUrl()) { 00044 Mage::getSingleton('customer/session')->setBeforeUrl($this->_getRefererUrl()); 00045 } 00046 } 00047 }
priceAction | ( | ) |
Definition at line 49 of file UnsubscribeController.php.
00050 { 00051 $productId = (int) $this->getRequest()->getParam('product'); 00052 00053 if (!$productId) { 00054 $this->_redirect(''); 00055 return; 00056 } 00057 $session = Mage::getSingleton('catalog/session'); 00058 00059 /* @var $session Mage_Catalog_Model_Session */ 00060 $product = Mage::getModel('catalog/product')->load($productId); 00061 if (!$product->getId() || !$product->isVisibleInCatalog()) { 00062 /* @var $product Mage_Catalog_Model_Product */ 00063 Mage::getSingleton('customer/session')->addError($this->__('Product not found')); 00064 $this->_redirect('customer/account/'); 00065 return ; 00066 } 00067 00068 try { 00069 $model = Mage::getModel('productalert/price') 00070 ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()) 00071 ->setProductId($product->getId()) 00072 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) 00073 ->loadByParam(); 00074 if ($model->getId()) { 00075 $model->delete(); 00076 } 00077 00078 $session->addSuccess($this->__('Alert subscription was deleted successfully')); 00079 } 00080 catch (Exception $e) { 00081 $session->addException($e, $this->__('Please try again later')); 00082 } 00083 $this->_redirectUrl($product->getProductUrl()); 00084 }
priceAllAction | ( | ) |
Definition at line 86 of file UnsubscribeController.php.
00087 { 00088 $session = Mage::getSingleton('customer/session'); 00089 /* @var $session Mage_Customer_Model_Session */ 00090 00091 try { 00092 Mage::getModel('productalert/price')->deleteCustomer( 00093 $session->getCustomerId(), 00094 Mage::app()->getStore()->getWebsiteId() 00095 ); 00096 $session->addSuccess($this->__('You will no longer receive price alerts for this product')); 00097 } 00098 catch (Exception $e) { 00099 $session->addException($e, $this->__('Please try again later')); 00100 } 00101 $this->_redirect('customer/account/'); 00102 }
stockAction | ( | ) |
Definition at line 104 of file UnsubscribeController.php.
00105 { 00106 $productId = (int) $this->getRequest()->getParam('product'); 00107 00108 if (!$productId) { 00109 $this->_redirect(''); 00110 return; 00111 } 00112 00113 $session = Mage::getSingleton('catalog/session'); 00114 /* @var $session Mage_Catalog_Model_Session */ 00115 $product = Mage::getModel('catalog/product')->load($productId); 00116 /* @var $product Mage_Catalog_Model_Product */ 00117 if (!$product->getId() || !$product->isVisibleInCatalog()) { 00118 Mage::getSingleton('customer/session')->addError($this->__('Product not found')); 00119 $this->_redirect('customer/account/'); 00120 return ; 00121 } 00122 00123 try { 00124 $model = Mage::getModel('productalert/stock') 00125 ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()) 00126 ->setProductId($product->getId()) 00127 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) 00128 ->loadByParam(); 00129 if ($model->getId()) { 00130 $model->delete(); 00131 } 00132 $session->addSuccess($this->__('You will no longer receive stock alerts for this product')); 00133 } 00134 catch (Exception $e) { 00135 $session->addException($e, $this->__('Please try again later')); 00136 } 00137 $this->_redirectUrl($product->getProductUrl()); 00138 }
stockAllAction | ( | ) |
Definition at line 140 of file UnsubscribeController.php.
00141 { 00142 $session = Mage::getSingleton('customer/session'); 00143 /* @var $session Mage_Customer_Model_Session */ 00144 00145 try { 00146 Mage::getModel('productalert/stock')->deleteCustomer( 00147 $session->getCustomerId(), 00148 Mage::app()->getStore()->getWebsiteId() 00149 ); 00150 $session->addSuccess($this->__('You will no longer receive stock alerts')); 00151 } 00152 catch (Exception $e) { 00153 $session->addException($e, $this->__('Please try again later')); 00154 } 00155 $this->_redirect('customer/account/'); 00156 }