Mage_Catalog_Model_Category_Api_V2 Class Reference

Inheritance diagram for Mage_Catalog_Model_Category_Api_V2:

Mage_Catalog_Model_Category_Api Mage_Catalog_Model_Api_Resource Mage_Api_Model_Resource_Abstract

List of all members.

Public Member Functions

 info ($categoryId, $store=null, $attributes=null)
 create ($parentId, $categoryData, $store=null)
 update ($categoryId, $categoryData, $store=null)


Detailed Description

Definition at line 34 of file V2.php.


Member Function Documentation

create ( parentId,
categoryData,
store = null 
)

Create new category

Parameters:
int $parentId
array $categoryData
Returns:
int

Reimplemented from Mage_Catalog_Model_Category_Api.

Definition at line 75 of file V2.php.

00076     {
00077         $parent_category = $this->_initCategory($parentId);
00078 
00079         $category = Mage::getModel('catalog/category')
00080             ->setStoreId($this->_getStoreId($store));
00081 
00082         $category->addData(array('path'=>implode('/',$parent_category->getPathIds())));
00083 
00084         $category ->setAttributeSetId($category->getDefaultAttributeSetId());
00085         /* @var $category Mage_Catalog_Model_Category */
00086 
00087         foreach ($category->getAttributes() as $attribute) {
00088             $_attrCode = $attribute->getAttributeCode();
00089             if ($this->_isAllowedAttribute($attribute)
00090                 && isset($categoryData->$_attrCode)) {
00091                 $category->setData(
00092                     $attribute->getAttributeCode(),
00093                     $categoryData->$_attrCode
00094                 );
00095             }
00096         }
00097         $category->setParentId($parent_category->getId());
00098         try {
00099             $category->save();
00100         } catch (Mage_Core_Exception $e) {
00101             $this->_fault('data_invalid', $e->getMessage());
00102         }
00103 
00104         return $category->getId();
00105     }

info ( categoryId,
store = null,
attributes = null 
)

Retrieve category data

Parameters:
int $categoryId
string|int $store
array $attributes
Returns:
array

Reimplemented from Mage_Catalog_Model_Category_Api.

Definition at line 44 of file V2.php.

00045     {
00046         $category = $this->_initCategory($categoryId, $store);
00047 
00048         // Basic category data
00049         $result = array();
00050         $result['category_id'] = $category->getId();
00051 
00052         $result['is_active']   = $category->getIsActive();
00053         $result['position']    = $category->getPosition();
00054         $result['level']       = $category->getLevel();
00055 
00056         foreach ($category->getAttributes() as $attribute) {
00057             if ($this->_isAllowedAttribute($attribute, $attributes)) {
00058                 $result[$attribute->getAttributeCode()] = $category->getDataUsingMethod($attribute->getAttributeCode());
00059             }
00060         }
00061         $result['parent_id']   = $category->getParentId();
00062         $result['children']           = $category->getChildren();
00063         $result['all_children']       = $category->getAllChildren();
00064 
00065         return $result;
00066     }

update ( categoryId,
categoryData,
store = null 
)

Update category data

Parameters:
int $categoryId
array $categoryData
string|int $store
Returns:
boolean

Reimplemented from Mage_Catalog_Model_Category_Api.

Definition at line 115 of file V2.php.

00116     {
00117         $category = $this->_initCategory($categoryId, $store);
00118 
00119         foreach ($category->getAttributes() as $attribute) {
00120             $_attrCode = $attribute->getAttributeCode();
00121             if ($this->_isAllowedAttribute($attribute)
00122                 && isset($categoryData->$_attrCode)) {
00123                 $category->setData(
00124                     $attribute->getAttributeCode(),
00125                     $categoryData->$_attrCode
00126                 );
00127             }
00128         }
00129 
00130         try {
00131             $category->save();
00132         } catch (Mage_Core_Exception $e) {
00133             $this->_fault('data_invalid', $e->getMessage());
00134         }
00135 
00136         return true;
00137     }


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