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_Customer_AccountController
  • Mage_Customer_AddressController
  • Mage_Customer_Block_Account
  • Mage_Customer_Block_Account_Dashboard
  • Mage_Customer_Block_Account_Dashboard_Address
  • Mage_Customer_Block_Account_Dashboard_Block
  • Mage_Customer_Block_Account_Dashboard_Hello
  • Mage_Customer_Block_Account_Dashboard_Info
  • Mage_Customer_Block_Account_Dashboard_Newsletter
  • Mage_Customer_Block_Account_Dashboard_Sidebar
  • Mage_Customer_Block_Account_Forgotpassword
  • Mage_Customer_Block_Account_Navigation
  • Mage_Customer_Block_Account_Resetpassword
  • Mage_Customer_Block_Address_Book
  • Mage_Customer_Block_Address_Edit
  • Mage_Customer_Block_Address_Renderer_Default
  • Mage_Customer_Block_Form_Edit
  • Mage_Customer_Block_Form_Login
  • Mage_Customer_Block_Form_Register
  • Mage_Customer_Block_Newsletter
  • Mage_Customer_Block_Widget_Abstract
  • Mage_Customer_Block_Widget_Dob
  • Mage_Customer_Block_Widget_Gender
  • Mage_Customer_Block_Widget_Name
  • Mage_Customer_Block_Widget_Taxvat
  • Mage_Customer_Helper_Address
  • Mage_Customer_Helper_Data
  • Mage_Customer_Model_Address
  • Mage_Customer_Model_Address_Abstract
  • Mage_Customer_Model_Address_Api
  • Mage_Customer_Model_Address_Api_V2
  • Mage_Customer_Model_Address_Config
  • Mage_Customer_Model_Api2_Customer
  • Mage_Customer_Model_Api2_Customer_Address
  • Mage_Customer_Model_Api2_Customer_Address_Rest
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Customer_V1
  • Mage_Customer_Model_Api2_Customer_Address_Validator
  • Mage_Customer_Model_Api2_Customer_Rest
  • Mage_Customer_Model_Api2_Customer_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Rest_Customer_V1
  • Mage_Customer_Model_Api_Resource
  • Mage_Customer_Model_Attribute
  • Mage_Customer_Model_Attribute_Backend_Data_Boolean
  • Mage_Customer_Model_Attribute_Data
  • Mage_Customer_Model_Attribute_Data_Abstract
  • Mage_Customer_Model_Attribute_Data_Boolean
  • Mage_Customer_Model_Attribute_Data_Date
  • Mage_Customer_Model_Attribute_Data_File
  • Mage_Customer_Model_Attribute_Data_Hidden
  • Mage_Customer_Model_Attribute_Data_Image
  • Mage_Customer_Model_Attribute_Data_Multiline
  • Mage_Customer_Model_Attribute_Data_Multiselect
  • Mage_Customer_Model_Attribute_Data_Postcode
  • Mage_Customer_Model_Attribute_Data_Select
  • Mage_Customer_Model_Attribute_Data_Text
  • Mage_Customer_Model_Attribute_Data_Textarea
  • Mage_Customer_Model_Config_Share
  • Mage_Customer_Model_Convert_Adapter_Customer
  • Mage_Customer_Model_Convert_Parser_Customer
  • Mage_Customer_Model_Customer
  • Mage_Customer_Model_Customer_Api
  • Mage_Customer_Model_Customer_Api_V2
  • Mage_Customer_Model_Customer_Attribute_Backend_Billing
  • Mage_Customer_Model_Customer_Attribute_Backend_Password
  • Mage_Customer_Model_Customer_Attribute_Backend_Shipping
  • Mage_Customer_Model_Customer_Attribute_Backend_Store
  • Mage_Customer_Model_Customer_Attribute_Backend_Website
  • Mage_Customer_Model_Customer_Attribute_Source_Group
  • Mage_Customer_Model_Customer_Attribute_Source_Store
  • Mage_Customer_Model_Customer_Attribute_Source_Website
  • Mage_Customer_Model_Entity_Address
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Entity_Address_Attribute_Collection
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Country
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Region
  • Mage_Customer_Model_Entity_Address_Collection
  • Mage_Customer_Model_Entity_Attribute
  • Mage_Customer_Model_Entity_Attribute_Collection
  • Mage_Customer_Model_Entity_Customer
  • Mage_Customer_Model_Entity_Customer_Collection
  • Mage_Customer_Model_Entity_Form_Attribute
  • Mage_Customer_Model_Entity_Form_Attribute_Collection
  • Mage_Customer_Model_Entity_Group
  • Mage_Customer_Model_Entity_Group_Collection
  • Mage_Customer_Model_Entity_Setup
  • Mage_Customer_Model_Entity_Wishlist_Collection
  • Mage_Customer_Model_Form
  • Mage_Customer_Model_Group
  • Mage_Customer_Model_Group_Api
  • Mage_Customer_Model_Group_Api_V2
  • Mage_Customer_Model_Observer
  • Mage_Customer_Model_Resource_Address
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Resource_Address_Attribute_Collection
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Country
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Region
  • Mage_Customer_Model_Resource_Address_Collection
  • Mage_Customer_Model_Resource_Attribute
  • Mage_Customer_Model_Resource_Attribute_Collection
  • Mage_Customer_Model_Resource_Customer
  • Mage_Customer_Model_Resource_Customer_Collection
  • Mage_Customer_Model_Resource_Form_Attribute
  • Mage_Customer_Model_Resource_Form_Attribute_Collection
  • Mage_Customer_Model_Resource_Group
  • Mage_Customer_Model_Resource_Group_Collection
  • Mage_Customer_Model_Resource_Setup
  • Mage_Customer_Model_Resource_Wishlist_Collection
  • Mage_Customer_Model_Session
  • Mage_Customer_ReviewController

Interfaces

  • Mage_Customer_Block_Address_Renderer_Interface

Exceptions

  • Mage_Customer_Exception
  • 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_Customer
 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:  * Customer address controller
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Customer
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Customer_AddressController extends Mage_Core_Controller_Front_Action
 36: {
 37:     /**
 38:      * Retrieve customer session object
 39:      *
 40:      * @return Mage_Customer_Model_Session
 41:      */
 42:     protected function _getSession()
 43:     {
 44:         return Mage::getSingleton('customer/session');
 45:     }
 46: 
 47:     public function preDispatch()
 48:     {
 49:         parent::preDispatch();
 50: 
 51:         if (!Mage::getSingleton('customer/session')->authenticate($this)) {
 52:             $this->setFlag('', 'no-dispatch', true);
 53:         }
 54:     }
 55: 
 56:     /**
 57:      * Customer addresses list
 58:      */
 59:     public function indexAction()
 60:     {
 61:         if (count($this->_getSession()->getCustomer()->getAddresses())) {
 62:             $this->loadLayout();
 63:             $this->_initLayoutMessages('customer/session');
 64:             $this->_initLayoutMessages('catalog/session');
 65: 
 66:             $block = $this->getLayout()->getBlock('address_book');
 67:             if ($block) {
 68:                 $block->setRefererUrl($this->_getRefererUrl());
 69:             }
 70:             $this->renderLayout();
 71:         } else {
 72:             $this->getResponse()->setRedirect(Mage::getUrl('*/*/new'));
 73:         }
 74:     }
 75: 
 76:     public function editAction()
 77:     {
 78:         $this->_forward('form');
 79:     }
 80: 
 81:     public function newAction()
 82:     {
 83:         $this->_forward('form');
 84:     }
 85: 
 86:     /**
 87:      * Address book form
 88:      */
 89:     public function formAction()
 90:     {
 91:         $this->loadLayout();
 92:         $this->_initLayoutMessages('customer/session');
 93:         $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
 94:         if ($navigationBlock) {
 95:             $navigationBlock->setActive('customer/address');
 96:         }
 97:         $this->renderLayout();
 98:     }
 99: 
100:     public function formPostAction()
101:     {
102:         if (!$this->_validateFormKey()) {
103:             return $this->_redirect('*/*/');
104:         }
105:         // Save data
106:         if ($this->getRequest()->isPost()) {
107:             $customer = $this->_getSession()->getCustomer();
108:             /* @var $address Mage_Customer_Model_Address */
109:             $address  = Mage::getModel('customer/address');
110:             $addressId = $this->getRequest()->getParam('id');
111:             if ($addressId) {
112:                 $existsAddress = $customer->getAddressById($addressId);
113:                 if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) {
114:                     $address->setId($existsAddress->getId());
115:                 }
116:             }
117: 
118:             $errors = array();
119: 
120:             /* @var $addressForm Mage_Customer_Model_Form */
121:             $addressForm = Mage::getModel('customer/form');
122:             $addressForm->setFormCode('customer_address_edit')
123:                 ->setEntity($address);
124:             $addressData    = $addressForm->extractData($this->getRequest());
125:             $addressErrors  = $addressForm->validateData($addressData);
126:             if ($addressErrors !== true) {
127:                 $errors = $addressErrors;
128:             }
129: 
130:             try {
131:                 $addressForm->compactData($addressData);
132:                 $address->setCustomerId($customer->getId())
133:                     ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
134:                     ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
135: 
136:                 $addressErrors = $address->validate();
137:                 if ($addressErrors !== true) {
138:                     $errors = array_merge($errors, $addressErrors);
139:                 }
140: 
141:                 if (count($errors) === 0) {
142:                     $address->save();
143:                     $this->_getSession()->addSuccess($this->__('The address has been saved.'));
144:                     $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
145:                     return;
146:                 } else {
147:                     $this->_getSession()->setAddressFormData($this->getRequest()->getPost());
148:                     foreach ($errors as $errorMessage) {
149:                         $this->_getSession()->addError($errorMessage);
150:                     }
151:                 }
152:             } catch (Mage_Core_Exception $e) {
153:                 $this->_getSession()->setAddressFormData($this->getRequest()->getPost())
154:                     ->addException($e, $e->getMessage());
155:             } catch (Exception $e) {
156:                 $this->_getSession()->setAddressFormData($this->getRequest()->getPost())
157:                     ->addException($e, $this->__('Cannot save address.'));
158:             }
159:         }
160: 
161:         return $this->_redirectError(Mage::getUrl('*/*/edit', array('id' => $address->getId())));
162:     }
163: 
164:     public function deleteAction()
165:     {
166:         $addressId = $this->getRequest()->getParam('id', false);
167: 
168:         if ($addressId) {
169:             $address = Mage::getModel('customer/address')->load($addressId);
170: 
171:             // Validate address_id <=> customer_id
172:             if ($address->getCustomerId() != $this->_getSession()->getCustomerId()) {
173:                 $this->_getSession()->addError($this->__('The address does not belong to this customer.'));
174:                 $this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
175:                 return;
176:             }
177: 
178:             try {
179:                 $address->delete();
180:                 $this->_getSession()->addSuccess($this->__('The address has been deleted.'));
181:             } catch (Exception $e){
182:                 $this->_getSession()->addException($e, $this->__('An error occurred while deleting the address.'));
183:             }
184:         }
185:         $this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
186:     }
187: }
188: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0