Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_ProductAlert_AddController
  • Mage_ProductAlert_Block_Email_Abstract
  • Mage_ProductAlert_Block_Email_Price
  • Mage_ProductAlert_Block_Email_Stock
  • Mage_ProductAlert_Block_Product_View
  • Mage_ProductAlert_Helper_Data
  • Mage_ProductAlert_Model_Email
  • Mage_ProductAlert_Model_Mysql4_Price
  • Mage_ProductAlert_Model_Mysql4_Price_Collection
  • Mage_ProductAlert_Model_Mysql4_Price_Customer_Collection
  • Mage_ProductAlert_Model_Mysql4_Stock
  • Mage_ProductAlert_Model_Mysql4_Stock_Collection
  • Mage_ProductAlert_Model_Mysql4_Stock_Customer_Collection
  • Mage_ProductAlert_Model_Observer
  • Mage_ProductAlert_Model_Price
  • Mage_ProductAlert_Model_Resource_Abstract
  • Mage_ProductAlert_Model_Resource_Price
  • Mage_ProductAlert_Model_Resource_Price_Collection
  • Mage_ProductAlert_Model_Resource_Price_Customer_Collection
  • Mage_ProductAlert_Model_Resource_Stock
  • Mage_ProductAlert_Model_Resource_Stock_Collection
  • Mage_ProductAlert_Model_Resource_Stock_Customer_Collection
  • Mage_ProductAlert_Model_Stock
  • Mage_ProductAlert_UnsubscribeController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_ProductAlert
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * ProductAlert unsubscribe controller
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_ProductAlert
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_ProductAlert_UnsubscribeController extends Mage_Core_Controller_Front_Action
 36: {
 37:     public function preDispatch()
 38:     {
 39:         parent::preDispatch();
 40: 
 41:         if (!Mage::getSingleton('customer/session')->authenticate($this)) {
 42:             $this->setFlag('', 'no-dispatch', true);
 43:             if(!Mage::getSingleton('customer/session')->getBeforeUrl()) {
 44:                 Mage::getSingleton('customer/session')->setBeforeUrl($this->_getRefererUrl());
 45:             }
 46:         }
 47:     }
 48: 
 49:     public function priceAction()
 50:     {
 51:         $productId  = (int) $this->getRequest()->getParam('product');
 52: 
 53:         if (!$productId) {
 54:             $this->_redirect('');
 55:             return;
 56:         }
 57:         $session    = Mage::getSingleton('catalog/session');
 58: 
 59:         /* @var $session Mage_Catalog_Model_Session */
 60:         $product = Mage::getModel('catalog/product')->load($productId);
 61:         if (!$product->getId() || !$product->isVisibleInCatalog()) {
 62:             /* @var $product Mage_Catalog_Model_Product */
 63:             Mage::getSingleton('customer/session')->addError($this->__('The product is not found.'));
 64:             $this->_redirect('customer/account/');
 65:             return ;
 66:         }
 67: 
 68:         try {
 69:             $model  = Mage::getModel('productalert/price')
 70:                 ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
 71:                 ->setProductId($product->getId())
 72:                 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
 73:                 ->loadByParam();
 74:             if ($model->getId()) {
 75:                 $model->delete();
 76:             }
 77: 
 78:             $session->addSuccess($this->__('The alert subscription has been deleted.'));
 79:         }
 80:         catch (Exception $e) {
 81:             $session->addException($e, $this->__('Unable to update the alert subscription.'));
 82:         }
 83:         $this->_redirectUrl($product->getProductUrl());
 84:     }
 85: 
 86:     public function priceAllAction()
 87:     {
 88:         $session = Mage::getSingleton('customer/session');
 89:         /* @var $session Mage_Customer_Model_Session */
 90: 
 91:         try {
 92:             Mage::getModel('productalert/price')->deleteCustomer(
 93:                 $session->getCustomerId(),
 94:                 Mage::app()->getStore()->getWebsiteId()
 95:             );
 96:             $session->addSuccess($this->__('You will no longer receive price alerts for this product.'));
 97:         }
 98:         catch (Exception $e) {
 99:             $session->addException($e, $this->__('Unable to update the alert subscription.'));
100:         }
101:         $this->_redirect('customer/account/');
102:     }
103: 
104:     public function stockAction()
105:     {
106:         $productId  = (int) $this->getRequest()->getParam('product');
107: 
108:         if (!$productId) {
109:             $this->_redirect('');
110:             return;
111:         }
112: 
113:         $session = Mage::getSingleton('catalog/session');
114:         /* @var $session Mage_Catalog_Model_Session */
115:         $product = Mage::getModel('catalog/product')->load($productId);
116:         /* @var $product Mage_Catalog_Model_Product */
117:         if (!$product->getId() || !$product->isVisibleInCatalog()) {
118:             Mage::getSingleton('customer/session')->addError($this->__('The product was not found.'));
119:             $this->_redirect('customer/account/');
120:             return ;
121:         }
122: 
123:         try {
124:             $model  = Mage::getModel('productalert/stock')
125:                 ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
126:                 ->setProductId($product->getId())
127:                 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
128:                 ->loadByParam();
129:             if ($model->getId()) {
130:                 $model->delete();
131:             }
132:             $session->addSuccess($this->__('You will no longer receive stock alerts for this product.'));
133:         }
134:         catch (Exception $e) {
135:             $session->addException($e, $this->__('Unable to update the alert subscription.'));
136:         }
137:         $this->_redirectUrl($product->getProductUrl());
138:     }
139: 
140:     public function stockAllAction()
141:     {
142:         $session = Mage::getSingleton('customer/session');
143:         /* @var $session Mage_Customer_Model_Session */
144: 
145:         try {
146:             Mage::getModel('productalert/stock')->deleteCustomer(
147:                 $session->getCustomerId(),
148:                 Mage::app()->getStore()->getWebsiteId()
149:             );
150:             $session->addSuccess($this->__('You will no longer receive stock alerts.'));
151:         }
152:         catch (Exception $e) {
153:             $session->addException($e, $this->__('Unable to update the alert subscription.'));
154:         }
155:         $this->_redirect('customer/account/');
156:     }
157: }
158: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0