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_Product_Attribute_Api extends Mage_Catalog_Model_Api_Resource
00035 {
00036 public function __construct()
00037 {
00038 $this->_storeIdSessionField = 'product_store_id';
00039 $this->_ignoredAttributeCodes[] = 'type_id';
00040 $this->_ignoredAttributeTypes[] = 'gallery';
00041 $this->_ignoredAttributeTypes[] = 'media_image';
00042 }
00043
00044
00045
00046
00047
00048
00049
00050 public function items($setId)
00051 {
00052 $attributes = Mage::getModel('catalog/product')->getResource()
00053 ->loadAllAttributes()
00054 ->getSortedAttributes($setId);
00055 $result = array();
00056
00057 foreach ($attributes as $attribute) {
00058
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 }
00082
00083
00084
00085
00086
00087
00088
00089
00090 public function options($attributeId, $store = null)
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
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 }
00118 }