Mage_Catalog_Model_Product_Attribute_Api Class Reference

Inheritance diagram for Mage_Catalog_Model_Product_Attribute_Api:

Mage_Catalog_Model_Api_Resource Mage_Api_Model_Resource_Abstract Mage_Catalog_Model_Product_Attribute_Api_V2

List of all members.

Public Member Functions

 __construct ()
 items ($setId)
 options ($attributeId, $store=null)


Detailed Description

Definition at line 34 of file Api.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 36 of file Api.php.

00037     {
00038         $this->_storeIdSessionField = 'product_store_id';
00039         $this->_ignoredAttributeCodes[] = 'type_id';
00040         $this->_ignoredAttributeTypes[] = 'gallery';
00041         $this->_ignoredAttributeTypes[] = 'media_image';
00042     }


Member Function Documentation

items ( setId  ) 

Retrieve attributes from specified attribute set

Parameters:
int $setId
Returns:
array

Definition at line 50 of file Api.php.

00051     {
00052         $attributes = Mage::getModel('catalog/product')->getResource()
00053                 ->loadAllAttributes()
00054                 ->getSortedAttributes($setId);
00055         $result = array();
00056 
00057         foreach ($attributes as $attribute) {
00058             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
00059             if ( (!$attribute->getId() || $attribute->isInSet($setId))
00060                 && $this->_isAllowedAttribute($attribute)) {
00061 
00062                 if (!$attribute->getId() || $attribute->isScopeGlobal()) {
00063                     $scope = 'global';
00064                 } elseif ($attribute->isScopeWebsite()) {
00065                     $scope = 'website';
00066                 } else {
00067                     $scope = 'store';
00068                 }
00069 
00070                 $result[] = array(
00071                     'attribute_id' => $attribute->getId(),
00072                     'code'         => $attribute->getAttributeCode(),
00073                     'type'         => $attribute->getFrontendInput(),
00074                     'required'     => $attribute->getIsRequired(),
00075                     'scope'        => $scope
00076                 );
00077             }
00078         }
00079 
00080         return $result;
00081     }

options ( attributeId,
store = null 
)

Retrieve attribute options

Parameters:
int $attributeId
string|int $store
Returns:
array

Definition at line 90 of file Api.php.

00091     {
00092         $storeId = $this->_getStoreId($store);
00093         $attribute = Mage::getModel('catalog/product')
00094             ->setStoreId($storeId)
00095             ->getResource()
00096             ->getAttribute($attributeId)
00097             ->setStoreId($storeId);
00098 
00099         /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
00100         if (!$attribute) {
00101             $this->_fault('not_exists');
00102         }
00103         $options = array();
00104         if ($attribute->usesSource()) {
00105             foreach ($attribute->getSource()->getAllOptions() as $optionId=>$optionValue) {
00106                 if (is_array($optionValue)) {
00107                     $options[] = $optionValue;
00108                 } else {
00109                     $options[] = array(
00110                         'value' => $optionId,
00111                         'label' => $optionValue
00112                     );
00113                 }
00114             }
00115         }
00116         return $options;
00117     }


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

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