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:  * API2 class for customer address rest
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Customer
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: abstract class Mage_Customer_Model_Api2_Customer_Address_Rest extends Mage_Customer_Model_Api2_Customer_Address
 35: {
 36:     /**
 37:      * Create customer address
 38:      *
 39:      * @param array $data
 40:      * @throws Mage_Api2_Exception
 41:      * @return string
 42:      */
 43:     protected function _create(array $data)
 44:     {
 45:         /* @var $customer Mage_Customer_Model_Customer */
 46:         $customer = $this->_loadCustomerById($this->getRequest()->getParam('customer_id'));
 47:         $validator = $this->_getValidator();
 48: 
 49:         $data = $validator->filter($data);
 50:         if (!$validator->isValidData($data) || !$validator->isValidDataForCreateAssociationWithCountry($data)) {
 51:             foreach ($validator->getErrors() as $error) {
 52:                 $this->_error($error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
 53:             }
 54:             $this->_critical(self::RESOURCE_DATA_PRE_VALIDATION_ERROR);
 55:         }
 56: 
 57:         if (isset($data['region']) && isset($data['country_id'])) {
 58:             $data['region'] = $this->_getRegionIdByNameOrCode($data['region'], $data['country_id']);
 59:         }
 60: 
 61:         /* @var $address Mage_Customer_Model_Address */
 62:         $address = Mage::getModel('customer/address');
 63:         $address->setData($data);
 64:         $address->setCustomer($customer);
 65: 
 66:         try {
 67:             $address->save();
 68:         } catch (Mage_Core_Exception $e) {
 69:             $this->_error($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
 70:         } catch (Exception $e) {
 71:             $this->_critical(self::RESOURCE_INTERNAL_ERROR);
 72:         }
 73:         return $this->_getLocation($address);
 74:     }
 75: 
 76:     /**
 77:      * Retrieve information about specified customer address
 78:      *
 79:      * @throws Mage_Api2_Exception
 80:      * @return array
 81:      */
 82:     protected function _retrieve()
 83:     {
 84:         /* @var $address Mage_Customer_Model_Address */
 85:         $address = $this->_loadCustomerAddressById($this->getRequest()->getParam('id'));
 86:         $addressData = $address->getData();
 87:         $addressData['street'] = $address->getStreet();
 88:         return $addressData;
 89:     }
 90: 
 91:     /**
 92:      * Get customer addresses list
 93:      *
 94:      * @return array
 95:      */
 96:     protected function _retrieveCollection()
 97:     {
 98:         $data = array();
 99:         /* @var $address Mage_Customer_Model_Address */
100:         foreach ($this->_getCollectionForRetrieve() as $address) {
101:             $addressData           = $address->getData();
102:             $addressData['street'] = $address->getStreet();
103:             $data[]                = array_merge($addressData, $this->_getDefaultAddressesInfo($address));
104:         }
105:         return $data;
106:     }
107: 
108:     /**
109:      * Retrieve collection instances
110:      *
111:      * @return Mage_Customer_Model_Resource_Address_Collection
112:      */
113:     protected function _getCollectionForRetrieve()
114:     {
115:         /* @var $customer Mage_Customer_Model_Customer */
116:         $customer = $this->_loadCustomerById($this->getRequest()->getParam('customer_id'));
117: 
118:         /* @var $collection Mage_Customer_Model_Resource_Address_Collection */
119:         $collection = $customer->getAddressesCollection();
120: 
121:         $this->_applyCollectionModifiers($collection);
122:         return $collection;
123:     }
124: 
125:     /**
126:      * Get array with default addresses information if possible
127:      *
128:      * @param Mage_Customer_Model_Address $address
129:      * @return array
130:      */
131:     protected function _getDefaultAddressesInfo(Mage_Customer_Model_Address $address)
132:     {
133:         return array(
134:             'is_default_billing'  => (int)$this->_isDefaultBillingAddress($address),
135:             'is_default_shipping' => (int)$this->_isDefaultShippingAddress($address)
136:         );
137:     }
138: 
139:     /**
140:      * Update specified stock item
141:      *
142:      * @param array $data
143:      * @throws Mage_Api2_Exception
144:      */
145:     protected function _update(array $data)
146:     {
147:         /* @var $address Mage_Customer_Model_Address */
148:         $address = $this->_loadCustomerAddressById($this->getRequest()->getParam('id'));
149:         $validator = $this->_getValidator();
150: 
151:         $data = $validator->filter($data);
152:         if (!$validator->isValidData($data, true)
153:             || !$validator->isValidDataForChangeAssociationWithCountry($address, $data)) {
154:             foreach ($validator->getErrors() as $error) {
155:                 $this->_error($error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
156:             }
157:             $this->_critical(self::RESOURCE_DATA_PRE_VALIDATION_ERROR);
158:         }
159:         if (isset($data['region'])) {
160:             $data['region'] = $this->_getRegionIdByNameOrCode(
161:                 $data['region'], isset($data['country_id']) ? $data['country_id'] : $address->getCountryId()
162:             );
163:             $data['region_id'] = null; // to avoid overwrite region during update in address model _beforeSave()
164:         }
165:         $address->addData($data);
166: 
167:         try {
168:             $address->save();
169:         } catch (Mage_Core_Exception $e) {
170:             $this->_error($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
171:         } catch (Exception $e) {
172:             $this->_critical(self::RESOURCE_INTERNAL_ERROR);
173:         }
174:     }
175: 
176:     /**
177:      * Delete customer
178:      */
179:     protected function _delete()
180:     {
181:         /* @var $address Mage_Customer_Model_Address */
182:         $address = $this->_loadCustomerAddressById($this->getRequest()->getParam('id'));
183: 
184:         if ($this->_isDefaultBillingAddress($address) || $this->_isDefaultShippingAddress($address)) {
185:             $this->_critical(
186:                 'Address is default for customer so is not allowed to be deleted',
187:                 Mage_Api2_Model_Server::HTTP_BAD_REQUEST
188:             );
189:         }
190:         try {
191:             $address->delete();
192:         } catch (Mage_Core_Exception $e) {
193:             $this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
194:         } catch (Exception $e) {
195:             $this->_critical(self::RESOURCE_INTERNAL_ERROR);
196:         }
197:     }
198: }
199: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0