Mage_Sales_Model_Api_Resource Class Reference

Inheritance diagram for Mage_Sales_Model_Api_Resource:

Mage_Api_Model_Resource_Abstract Mage_Sales_Model_Order_Api Mage_Sales_Model_Order_Invoice_Api Mage_Sales_Model_Order_Shipment_Api Mage_Sales_Model_Order_Api_V2 Mage_Sales_Model_Order_Invoice_Api_V2 Mage_Sales_Model_Order_Shipment_Api_V2

List of all members.

Protected Member Functions

 _updateAttributes ($data, $object, $type, array $attributes=null)
 _getAttributes ($object, $type, array $attributes=null)
 _isAllowedAttribute ($attributeCode, $type, array $attributes=null)

Protected Attributes

 $_ignoredAttributeCodes
 $_attributesMap


Detailed Description

Definition at line 34 of file Resource.php.


Member Function Documentation

_getAttributes ( object,
type,
array attributes = null 
) [protected]

Retrieve entity attributes values

Parameters:
Mage_Core_Model_Abstract $object
array $attributes
Returns:
Mage_Sales_Model_Api_Resource

Definition at line 81 of file Resource.php.

00082     {
00083         $result = array();
00084 
00085         if (!is_object($object)) {
00086             return $result;
00087         }
00088 
00089         foreach ($object->getData() as $attribute=>$value) {
00090             if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
00091                 $result[$attribute] = $value;
00092             }
00093         }
00094 
00095         foreach ($this->_attributesMap['global'] as $alias=>$attributeCode) {
00096             $result[$alias] = $object->getData($attributeCode);
00097         }
00098 
00099         if (isset($this->_attributesMap[$type])) {
00100             foreach ($this->_attributesMap[$type] as $alias=>$attributeCode) {
00101                 $result[$alias] = $object->getData($attributeCode);
00102             }
00103         }
00104 
00105         return $result;
00106     }

_isAllowedAttribute ( attributeCode,
type,
array attributes = null 
) [protected]

Check is attribute allowed to usage

Parameters:
Mage_Eav_Model_Entity_Attribute_Abstract $attribute
string $entityType
array $attributes
Returns:
boolean

Definition at line 116 of file Resource.php.

00117     {
00118         if (!empty($attributes)
00119             && !(in_array($attributeCode, $attributes))) {
00120             return false;
00121         }
00122 
00123         if (in_array($attributeCode, $this->_ignoredAttributeCodes['global'])) {
00124             return false;
00125         }
00126 
00127         if (isset($this->_ignoredAttributeCodes[$type])
00128             && in_array($attributeCode, $this->_ignoredAttributeCodes[$type])) {
00129             return false;
00130         }
00131 
00132         return true;
00133     }

_updateAttributes ( data,
object,
type,
array attributes = null 
) [protected]

Update attributes for entity

Parameters:
array $data
Mage_Core_Model_Abstract $object
array $attributes
Returns:
Mage_Sales_Model_Api_Resource

Definition at line 62 of file Resource.php.

00063     {
00064 
00065         foreach ($data as $attribute=>$value) {
00066             if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
00067                 $object->setData($attribute, $value);
00068             }
00069         }
00070 
00071         return $this;
00072     }


Member Data Documentation

$_attributesMap [protected]

Initial value:

 array(
        'global'    => array()
    )

Definition at line 50 of file Resource.php.

$_ignoredAttributeCodes [protected]

Initial value:

 array(
        'global'    =>  array('entity_id', 'attribute_set_id', 'entity_type_id')
    )

Definition at line 41 of file Resource.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:40 2009 for Magento by  doxygen 1.5.8