/** * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased. * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return array */ public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { $options = array(); if ($attribute->usesSource()) { // should attribute has index (option value) instead of a label? $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label'; // only default (admin) store values used $attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID); try { foreach ($attribute->getSource()->getAllOptions(false) as $option) { foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) { if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option $options[$innerOption['value']] = $innerOption[$index]; } } } } catch (Exception $e) { // ignore exceptions connected with source models } } return $options; }
/** * Get attribute type for upcoming validation. * * @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute $attribute * @return string */ public static function getAttributeType(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->usesSource()) { return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select'; } elseif ($attribute->isStatic()) { return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar'; } else { return $attribute->getBackendType(); } }
/** * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased. * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return array */ public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { $options = array(); if ($attribute->usesSource()) { // should attribute has index (option value) instead of a label? $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label'; /* MEP changed admin store to current profile store id */ $attribute->setStoreId($this->getProfile()->getStoreId()); try { foreach ($attribute->getSource()->getAllOptions(false) as $option) { foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) { if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option $options[$innerOption['value']] = $innerOption[$index]; } } } } catch (Exception $e) { // ignore exceptions connected with source models } } return $options; }