protected function _prepareValueOptions() { // Check that both keys exist. Maybe somehow only one was set not in this routine, but externally. $selectReady = $this->getData('value_select_options'); $hashedReady = $this->getData('value_option'); if ($selectReady && $hashedReady) { return $this; } // Get array of select options. It will be used as source for hashed options $selectOptions = null; if ($this->getAttribute() === 'attribute_set_id') { $entityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId(); $selectOptions = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($entityTypeId)->load()->toOptionArray(); } elseif ($this->getAttribute() === 'is_in_stock') { $selectOptions = array(); $options = Mage::getSingleton('cataloginventory/source_stock')->toOptionArray(); foreach ($options as $option) { $selectOptions[$option['value']] = $option; } } elseif ($this->getAttribute() === 'is_salable') { $selectOptions = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(); } elseif ($this->getAttribute() === 'type_id') { $selectOptions = Mage::getSingleton('catalog/product_type')->getAllOptions(); } elseif ($this->getAttribute() === 'status_parent') { $selectOptions = Mage_Catalog_Model_Product_Status::getAllOptions(); } elseif (is_object($this->getAttributeObject())) { $attributeObject = $this->getAttributeObject(); if ($attributeObject->usesSource()) { if ($attributeObject->getFrontendInput() == 'multiselect') { $addEmptyOption = false; } else { $addEmptyOption = true; } $selectOptions = $attributeObject->getSource()->getAllOptions($addEmptyOption); } } // Set new values only if we really got them if ($selectOptions !== null) { // Overwrite only not already existing values if (!$selectReady) { $this->setData('value_select_options', $selectOptions); } if (!$hashedReady) { $hashedOptions = array(); foreach ($selectOptions as $o) { if (is_array($o)) { if (is_array($o['value'])) { continue; // We cannot use array as index } $hashedOptions[$o['value']] = $o['label']; } } $this->setData('value_option', $hashedOptions); } } return $this; }