00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Catalog_Model_Category_Attribute_Api extends Mage_Catalog_Model_Api_Resource
00035 {
00036 public function __construct()
00037 {
00038 $this->_storeIdSessionField = 'category_store_id';
00039 }
00040
00041
00042
00043
00044
00045
00046 public function items()
00047 {
00048 $attributes = Mage::getModel('catalog/category')->getAttributes();
00049 $result = array();
00050
00051 foreach ($attributes as $attribute) {
00052
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 }
00074
00075
00076
00077
00078
00079
00080
00081
00082 public function options($attributeId, $store = null)
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 }
00109 }