/**
  * Check whether attribute instance (attribute, backend, frontend or source) has method and applicable
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute_Backend_Abstract|Mage_Eav_Model_Entity_Attribute_Frontend_Abstract|Mage_Eav_Model_Entity_Attribute_Source_Abstract $instance
  * @param string $method
  * @param array $args array of arguments
  * @return boolean
  */
 protected function _isCallableAttributeInstance($instance, $method, $args)
 {
     if ($instance instanceof Mage_Eav_Model_Entity_Attribute_Backend_Abstract && ($method == 'beforeSave' || ($method = 'afterSave'))) {
         $attributeCode = $instance->getAttribute()->getAttributeCode();
         if (isset($args[0]) && $args[0] instanceof Varien_Object && $args[0]->getData($attributeCode) === false) {
             return false;
         }
     }
     return parent::_isCallableAttributeInstance($instance, $method, $args);
 }
Пример #2
0
 /**
  * Bugfix for Magento 1.3 - do not return the option array entry, only the label.
  *
  * @param mixed $value
  * @return string
  */
 public function getOptionText($value)
 {
     $option = parent::getOptionText($value);
     if (is_array($option) && isset($option['label'])) {
         $option = $option['label'];
     }
     return $option;
 }
Пример #3
0
 /**
  * Get a text for index option value
  *
  * @param  string|int $value
  * @return string|bool
  */
 public function getIndexOptionText($value)
 {
     switch ($value) {
         case self::VALUE_YES:
             return 'Yes';
         case self::VALUE_NO:
             return 'No';
     }
     return parent::getIndexOptionText($value);
 }
Пример #4
0
 /**
  * Check whether attribute instance (attribute, backend, frontend or source) has method and applicable
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute_Backend_Abstract|Mage_Eav_Model_Entity_Attribute_Frontend_Abstract|Mage_Eav_Model_Entity_Attribute_Source_Abstract $instance
  * @param string $method
  * @param array $args array of arguments
  * @return boolean
  */
 protected function _isCallableAttributeInstance($instance, $method, $args)
 {
     if ($instance instanceof Mage_Eav_Model_Entity_Attribute_Backend_Abstract && ($method == 'beforeSave' || ($method = 'afterSave'))) {
         $attributeCode = $instance->getAttribute()->getAttributeCode();
         if (isset($args[0]) && $args[0] instanceof Varien_Object && $args[0]->getData($attributeCode) === false) {
             return false;
         }
     }
     if (!is_object($instance) || !method_exists($instance, $method)) {
         return false;
     }
     if (method_exists(get_parent_class(__CLASS__), '_isCallableAttributeInstance')) {
         return parent::_isCallableAttributeInstance($instance, $method, $args);
     } else {
         return true;
     }
 }
Пример #5
0
 /**
  * Constructor
  */
 protected function _construct()
 {
     parent::_construct();
 }
Пример #6
0
 /**
  * Get option as hash
  *
  * @param Mage_Eav_Model_Entity_Attribute_Source_Abstract $sourceModel
  * @return array
  */
 private function getOptions(Mage_Eav_Model_Entity_Attribute_Source_Abstract $sourceModel)
 {
     $result = array();
     foreach ($sourceModel->getAllOptions() as $option) {
         if ($option['value'] != '') {
             $result[$option['value']] = $option['label'];
         }
     }
     return $result;
 }