Public Member Functions | |
__construct () | |
items ($setId) | |
options ($attributeId, $store=null) |
Definition at line 34 of file Api.php.
__construct | ( | ) |
items | ( | $ | setId | ) |
Retrieve attributes from specified attribute set
int | $setId |
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
int | $attributeId | |
string|int | $store |
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 }