Mage_Catalog_Model_Category_Attribute_Api Class Reference

Inheritance diagram for Mage_Catalog_Model_Category_Attribute_Api:

Mage_Catalog_Model_Api_Resource Mage_Api_Model_Resource_Abstract Mage_Catalog_Model_Category_Attribute_Api_V2

List of all members.

Public Member Functions

 __construct ()
 items ()
 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 = 'category_store_id';
00039     }


Member Function Documentation

items (  ) 

Retrieve category attributes

Returns:
array

Definition at line 46 of file Api.php.

00047     {
00048         $attributes = Mage::getModel('catalog/category')->getAttributes();
00049         $result = array();
00050 
00051         foreach ($attributes as $attribute) {
00052             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
00053             if ($this->_isAllowedAttribute($attribute)) {
00054                 if (!$attribute->getId() || $attribute->isScopeGlobal()) {
00055                     $scope = 'global';
00056                 } elseif ($attribute->isScopeWebsite()) {
00057                     $scope = 'website';
00058                 } else {
00059                     $scope = 'store';
00060                 }
00061 
00062                 $result[] = array(
00063                     'attribute_id' => $attribute->getId(),
00064                     'code'         => $attribute->getAttributeCode(),
00065                     'type'         => $attribute->getFrontendInput(),
00066                     'required'     => $attribute->getIsRequired(),
00067                     'scope'        => $scope
00068                 );
00069             }
00070         }
00071 
00072         return $result;
00073     }

options ( attributeId,
store = null 
)

Retrieve category attribute options

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

Definition at line 82 of file Api.php.

00083     {
00084         $attribute = Mage::getModel('catalog/category')
00085             ->setStoreId($this->_getStoreId($store))
00086             ->getResource()
00087             ->getAttribute($attributeId);
00088 
00089         if (!$attribute) {
00090             $this->_fault('not_exists');
00091         }
00092 
00093         $result = array();
00094         if ($attribute->usesSource()) {
00095             foreach ($attribute->getSource()->getAllOptions() as $optionId=>$optionValue) {
00096                 if (is_array($optionValue)) {
00097                     $result[] = $optionValue;
00098                 } else {
00099                     $result[] = array(
00100                         'value' => $optionId,
00101                         'label' => $optionValue
00102                     );
00103                 }
00104             }
00105         }
00106 
00107         return $result;
00108     }


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

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