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:  * Customer address api
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Customer
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Customer_Model_Address_Api extends Mage_Customer_Model_Api_Resource
 35: {
 36:     protected $_mapAttributes = array(
 37:         'customer_address_id' => 'entity_id'
 38:     );
 39: 
 40:     public function __construct()
 41:     {
 42:         $this->_ignoredAttributeCodes[] = 'parent_id';
 43:     }
 44: 
 45:     /**
 46:      * Retrive customer addresses list
 47:      *
 48:      * @param int $customerId
 49:      * @return array
 50:      */
 51:     public function items($customerId)
 52:     {
 53:         $customer = Mage::getModel('customer/customer')
 54:             ->load($customerId);
 55:         /* @var $customer Mage_Customer_Model_Customer */
 56: 
 57:         if (!$customer->getId()) {
 58:             $this->_fault('customer_not_exists');
 59:         }
 60: 
 61:         $result = array();
 62:         foreach ($customer->getAddresses() as $address) {
 63:             $data = $address->toArray();
 64:             $row  = array();
 65: 
 66:             foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
 67:                 $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null;
 68:             }
 69: 
 70:             foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
 71:                 if (isset($data[$attributeCode])) {
 72:                     $row[$attributeCode] = $data[$attributeCode];
 73:                 }
 74:             }
 75: 
 76:             $row['is_default_billing'] = $customer->getDefaultBilling() == $address->getId();
 77:             $row['is_default_shipping'] = $customer->getDefaultShipping() == $address->getId();
 78: 
 79:             $result[] = $row;
 80: 
 81:         }
 82: 
 83:         return $result;
 84:     }
 85: 
 86:     /**
 87:      * Create new address for customer
 88:      *
 89:      * @param int $customerId
 90:      * @param array $addressData
 91:      * @return int
 92:      */
 93:     public function create($customerId, $addressData)
 94:     {
 95:         $customer = Mage::getModel('customer/customer')
 96:             ->load($customerId);
 97:         /* @var $customer Mage_Customer_Model_Customer */
 98: 
 99:         if (!$customer->getId()) {
100:             $this->_fault('customer_not_exists');
101:         }
102: 
103:         $address = Mage::getModel('customer/address');
104: 
105:         foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
106:             if (isset($addressData[$attributeCode])) {
107:                 $address->setData($attributeCode, $addressData[$attributeCode]);
108:             }
109:         }
110: 
111:         if (isset($addressData['is_default_billing'])) {
112:             $address->setIsDefaultBilling($addressData['is_default_billing']);
113:         }
114: 
115:         if (isset($addressData['is_default_shipping'])) {
116:             $address->setIsDefaultShipping($addressData['is_default_shipping']);
117:         }
118: 
119:         $address->setCustomerId($customer->getId());
120: 
121:         $valid = $address->validate();
122: 
123:         if (is_array($valid)) {
124:             $this->_fault('data_invalid', implode("\n", $valid));
125:         }
126: 
127:         try {
128:             $address->save();
129:         } catch (Mage_Core_Exception $e) {
130:             $this->_fault('data_invalid', $e->getMessage());
131:         }
132: 
133:         return $address->getId();
134:     }
135: 
136:     /**
137:      * Retrieve address data
138:      *
139:      * @param int $addressId
140:      * @return array
141:      */
142:     public function info($addressId)
143:     {
144:         $address = Mage::getModel('customer/address')
145:             ->load($addressId);
146: 
147:         if (!$address->getId()) {
148:             $this->_fault('not_exists');
149:         }
150: 
151:         $result = array();
152: 
153:         foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
154:             $result[$attributeAlias] = $address->getData($attributeCode);
155:         }
156: 
157:         foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
158:             $result[$attributeCode] = $address->getData($attributeCode);
159:         }
160: 
161: 
162:         if ($customer = $address->getCustomer()) {
163:             $result['is_default_billing']  = $customer->getDefaultBilling() == $address->getId();
164:             $result['is_default_shipping'] = $customer->getDefaultShipping() == $address->getId();
165:         }
166: 
167:         return $result;
168:     }
169: 
170:     /**
171:      * Update address data
172:      *
173:      * @param int $addressId
174:      * @param array $addressData
175:      * @return boolean
176:      */
177:     public function update($addressId, $addressData)
178:     {
179:         $address = Mage::getModel('customer/address')
180:             ->load($addressId);
181: 
182:         if (!$address->getId()) {
183:             $this->_fault('not_exists');
184:         }
185: 
186:         foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
187:             if (isset($addressData[$attributeCode])) {
188:                 $address->setData($attributeCode, $addressData[$attributeCode]);
189:             }
190:         }
191: 
192:         if (isset($addressData['is_default_billing'])) {
193:             $address->setIsDefaultBilling($addressData['is_default_billing']);
194:         }
195: 
196:         if (isset($addressData['is_default_shipping'])) {
197:             $address->setIsDefaultShipping($addressData['is_default_shipping']);
198:         }
199: 
200:         $valid = $address->validate();
201:         if (is_array($valid)) {
202:             $this->_fault('data_invalid', implode("\n", $valid));
203:         }
204: 
205:         try {
206:             $address->save();
207:         } catch (Mage_Core_Exception $e) {
208:             $this->_fault('data_invalid', $e->getMessage());
209:         }
210: 
211:         return true;
212:     }
213: 
214:     /**
215:      * Delete address
216:      *
217:      * @param int $addressId
218:      * @return boolean
219:      */
220:     public function delete($addressId)
221:     {
222:         $address = Mage::getModel('customer/address')
223:             ->load($addressId);
224: 
225:         if (!$address->getId()) {
226:             $this->_fault('not_exists');
227:         }
228: 
229:         try {
230:             $address->delete();
231:         } catch (Mage_Core_Exception $e) {
232:             $this->_fault('not_deleted', $e->getMessage());
233:         }
234: 
235:         return true;
236:     }
237: } // Class Mage_Customer_Model_Address_Api End
238: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0