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_Checkout_Block_Agreements
  • Mage_Checkout_Block_Cart
  • Mage_Checkout_Block_Cart_Abstract
  • Mage_Checkout_Block_Cart_Coupon
  • Mage_Checkout_Block_Cart_Crosssell
  • Mage_Checkout_Block_Cart_Item_Configure
  • Mage_Checkout_Block_Cart_Item_Renderer
  • Mage_Checkout_Block_Cart_Item_Renderer_Configurable
  • Mage_Checkout_Block_Cart_Item_Renderer_Grouped
  • Mage_Checkout_Block_Cart_Shipping
  • Mage_Checkout_Block_Cart_Sidebar
  • Mage_Checkout_Block_Cart_Totals
  • Mage_Checkout_Block_Links
  • Mage_Checkout_Block_Multishipping_Abstract
  • Mage_Checkout_Block_Multishipping_Address_Select
  • Mage_Checkout_Block_Multishipping_Addresses
  • Mage_Checkout_Block_Multishipping_Billing
  • Mage_Checkout_Block_Multishipping_Billing_Items
  • Mage_Checkout_Block_Multishipping_Link
  • Mage_Checkout_Block_Multishipping_Overview
  • Mage_Checkout_Block_Multishipping_Payment_Info
  • Mage_Checkout_Block_Multishipping_Shipping
  • Mage_Checkout_Block_Multishipping_State
  • Mage_Checkout_Block_Multishipping_Success
  • Mage_Checkout_Block_Onepage
  • Mage_Checkout_Block_Onepage_Abstract
  • Mage_Checkout_Block_Onepage_Billing
  • Mage_Checkout_Block_Onepage_Failure
  • Mage_Checkout_Block_Onepage_Link
  • Mage_Checkout_Block_Onepage_Login
  • Mage_Checkout_Block_Onepage_Payment
  • Mage_Checkout_Block_Onepage_Payment_Info
  • Mage_Checkout_Block_Onepage_Payment_Methods
  • Mage_Checkout_Block_Onepage_Progress
  • Mage_Checkout_Block_Onepage_Review
  • Mage_Checkout_Block_Onepage_Review_Info
  • Mage_Checkout_Block_Onepage_Shipping
  • Mage_Checkout_Block_Onepage_Shipping_Method
  • Mage_Checkout_Block_Onepage_Shipping_Method_Additional
  • Mage_Checkout_Block_Onepage_Shipping_Method_Available
  • Mage_Checkout_Block_Onepage_Success
  • Mage_Checkout_Block_Success
  • Mage_Checkout_Block_Total_Default
  • Mage_Checkout_Block_Total_Nominal
  • Mage_Checkout_Block_Total_Tax
  • Mage_Checkout_CartController
  • Mage_Checkout_Controller_Action
  • Mage_Checkout_Exception
  • Mage_Checkout_Helper_Cart
  • Mage_Checkout_Helper_Data
  • Mage_Checkout_Helper_Url
  • Mage_Checkout_IndexController
  • Mage_Checkout_Model_Agreement
  • Mage_Checkout_Model_Api_Resource
  • Mage_Checkout_Model_Api_Resource_Customer
  • Mage_Checkout_Model_Api_Resource_Product
  • Mage_Checkout_Model_Cart
  • Mage_Checkout_Model_Cart_Api
  • Mage_Checkout_Model_Cart_Api_V2
  • Mage_Checkout_Model_Cart_Coupon_Api
  • Mage_Checkout_Model_Cart_Coupon_Api_V2
  • Mage_Checkout_Model_Cart_Customer_Api
  • Mage_Checkout_Model_Cart_Customer_Api_V2
  • Mage_Checkout_Model_Cart_Payment_Api
  • Mage_Checkout_Model_Cart_Payment_Api_V2
  • Mage_Checkout_Model_Cart_Product_Api
  • Mage_Checkout_Model_Cart_Product_Api_V2
  • Mage_Checkout_Model_Cart_Shipping_Api
  • Mage_Checkout_Model_Cart_Shipping_Api_V2
  • Mage_Checkout_Model_Config_Source_Cart_Summary
  • Mage_Checkout_Model_Mysql4_Agreement
  • Mage_Checkout_Model_Mysql4_Agreement_Collection
  • Mage_Checkout_Model_Mysql4_Cart
  • Mage_Checkout_Model_Mysql4_Setup
  • Mage_Checkout_Model_Observer
  • Mage_Checkout_Model_Resource_Agreement
  • Mage_Checkout_Model_Resource_Agreement_Collection
  • Mage_Checkout_Model_Resource_Cart
  • Mage_Checkout_Model_Resource_Setup
  • Mage_Checkout_Model_Session
  • Mage_Checkout_Model_Type_Abstract
  • Mage_Checkout_Model_Type_Multishipping
  • Mage_Checkout_Model_Type_Multishipping_State
  • Mage_Checkout_Model_Type_Onepage
  • Mage_Checkout_Multishipping_AddressController
  • Mage_Checkout_MultishippingController
  • Mage_Checkout_OnepageController

Interfaces

  • Mage_Checkout_Model_Cart_Interface
  • 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_Checkout
 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:  * Checkout api resource
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Checkout
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Checkout_Model_Api_Resource extends Mage_Api_Model_Resource_Abstract
 35: {
 36:     /**
 37:      * Attributes map array per entity type
 38:      *
 39:      * @var array
 40:      */
 41:     protected $_attributesMap = array(
 42:         'global' => array(),
 43:     );
 44: 
 45:     /**
 46:      * Default ignored attribute codes per entity type
 47:      *
 48:      * @var array
 49:      */
 50:     protected $_ignoredAttributeCodes = array(
 51:         'global'    =>  array('entity_id', 'attribute_set_id', 'entity_type_id')
 52:     );
 53: 
 54:     /**
 55:      * Field name in session for saving store id
 56:      * @var string
 57:      */
 58:     protected $_storeIdSessionField   = 'store_id';
 59: 
 60: 
 61:     /**
 62:      * Check if quote already exist with provided quoteId for creating
 63:      *
 64:      * @param int $quoteId
 65:      * @return bool
 66:      */
 67:     protected function _isQuoteExist($quoteId)
 68:     {
 69:         if (empty($quoteId)) {
 70:             return false;
 71:         }
 72: 
 73:         try {
 74:             $quote = $this->_getQuote($quoteId);
 75:         } catch (Mage_Api_Exception $e) {
 76:             return false;
 77:         }
 78: 
 79:         if (!is_null($quote->getId())) {
 80:             $this->_fault('quote_already_exist');
 81:         }
 82: 
 83:         return false;
 84:     }
 85: 
 86:     /**
 87:      * Retrieves store id from store code, if no store id specified,
 88:      * it use set session or admin store
 89:      *
 90:      * @param string|int $store
 91:      * @return int
 92:      */
 93:     protected function _getStoreId($store = null)
 94:     {
 95:         if (is_null($store)) {
 96:             $store = ($this->_getSession()->hasData($this->_storeIdSessionField)
 97:                         ? $this->_getSession()->getData($this->_storeIdSessionField) : 0);
 98:         }
 99: 
100:         try {
101:             $storeId = Mage::app()->getStore($store)->getId();
102: 
103:         } catch (Mage_Core_Model_Store_Exception $e) {
104:             $this->_fault('store_not_exists');
105:         }
106: 
107:         return $storeId;
108:     }
109: 
110:     /**
111:      * Retrieves quote by quote identifier and store code or by quote identifier
112:      *
113:      * @param int $quoteId
114:      * @param string|int $store
115:      * @return Mage_Sales_Model_Quote
116:      */
117:     protected function _getQuote($quoteId, $store = null)
118:     {
119:         /** @var $quote Mage_Sales_Model_Quote */
120:         $quote = Mage::getModel("sales/quote");
121: 
122:         if (!(is_string($store) || is_integer($store))) {
123:             $quote->loadByIdWithoutStore($quoteId);
124:         } else {
125:             $storeId = $this->_getStoreId($store);
126: 
127:             $quote->setStoreId($storeId)
128:                     ->load($quoteId);
129:         }
130:         if (is_null($quote->getId())) {
131:             $this->_fault('quote_not_exists');
132:         }
133: 
134:         return $quote;
135:     }
136: 
137:     /**
138:      * Get store identifier by quote identifier
139:      *
140:      * @param int $quoteId
141:      * @return int
142:      */
143:     protected function _getStoreIdFromQuote($quoteId)
144:     {
145:         /** @var $quote Mage_Sales_Model_Quote */
146:         $quote = Mage::getModel('sales/quote')
147:                 ->loadByIdWithoutStore($quoteId);
148: 
149:         return $quote->getStoreId();
150:     }
151: 
152:     /**
153:      * Update attributes for entity
154:      *
155:      * @param array $data
156:      * @param Mage_Core_Model_Abstract $object
157:      * @param string $type
158:      * @param array|null $attributes
159:      * @return Mage_Checkout_Model_Api_Resource
160:      */
161:     protected function _updateAttributes($data, $object, $type,  array $attributes = null)
162:     {
163:         foreach ($data as $attribute=>$value) {
164:             if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
165:                 $object->setData($attribute, $value);
166:             }
167:         }
168: 
169:         return $this;
170:     }
171: 
172:     /**
173:      * Retrieve entity attributes values
174:      *
175:      * @param Mage_Core_Model_Abstract $object
176:      * @param string $type
177:      * @param array $attributes
178:      * @return Mage_Checkout_Model_Api_Resource
179:      */
180:     protected function _getAttributes($object, $type, array $attributes = null)
181:     {
182:         $result = array();
183: 
184:         if (!is_object($object)) {
185:             return $result;
186:         }
187: 
188:         foreach ($object->getData() as $attribute=>$value) {
189:             if (is_object($value)) {
190:                 continue;
191:             }
192: 
193:             if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
194:                 $result[$attribute] = $value;
195:             }
196:         }
197: 
198:         foreach ($this->_attributesMap['global'] as $alias=>$attributeCode) {
199:             $result[$alias] = $object->getData($attributeCode);
200:         }
201: 
202:         if (isset($this->_attributesMap[$type])) {
203:             foreach ($this->_attributesMap[$type] as $alias=>$attributeCode) {
204:                 $result[$alias] = $object->getData($attributeCode);
205:             }
206:         }
207: 
208:         return $result;
209:     }
210: 
211:     /**
212:      * Check is attribute allowed to usage
213:      *
214:      * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
215:      * @param string $type
216:      * @param array $attributes
217:      * @return bool
218:      */
219:     protected function _isAllowedAttribute($attributeCode, $type, array $attributes = null)
220:     {
221:         if (!empty($attributes)
222:             && !(in_array($attributeCode, $attributes))) {
223:             return false;
224:         }
225: 
226:         if (in_array($attributeCode, $this->_ignoredAttributeCodes['global'])) {
227:             return false;
228:         }
229: 
230:         if (isset($this->_ignoredAttributeCodes[$type])
231:             && in_array($attributeCode, $this->_ignoredAttributeCodes[$type])) {
232:             return false;
233:         }
234: 
235:         return true;
236:     }
237: 
238: }
239: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0