Esempio n. 1
0
 public static function toOptionArray()
 {
     $options = array(array('value' => '', 'label' => ''));
     foreach (Mage_Catalog_Model_Product_Status::getOptionArray() as $value => $label) {
         $options[] = array('value' => $value, 'label' => $label);
     }
     return $options;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 public function __construct()
 {
     parent::__construct();
     $eav_name = Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_product', 'status');
     $this->setAttribute($eav_name);
 }