Beispiel #1
0
 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     if ($attribute->getIsFilterable() == 0 && $attribute->getIsVisibleInAdvancedSearch() == 0) {
         return false;
     }
     if ($attribute->getFrontendInput() != 'select' && $attribute->getFrontendInput() != 'multiselect') {
         return false;
     }
     return true;
 }
 /**
  * Check is attribute allowed
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array $attributes
  * @return boolean
  */
 protected function _isAllowedAttribute($attribute, array $filter = null)
 {
     if (!is_null($filter) && !(in_array($attribute->getAttributeCode(), $filter) || in_array($attribute->getAttributeId(), $filter))) {
         return false;
     }
     return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes);
 }
 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     if ($attribute->getFrontendInput() != 'price') {
         return false;
     }
     if ($attribute->getAttributeCode() == 'tier_price') {
         return false;
     }
     if ($attribute->getAttributeCode() == 'minimal_price') {
         return false;
     }
     return true;
 }
Beispiel #4
0
 /**
  * Check if attribute allowed
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array $attributes
  * @return boolean
  */
 protected function _isAllowedAttribute($attribute)
 {
     return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes) && $attribute->getFrontendLabel() != "";
 }
Beispiel #5
0
 /**
  * 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();
     }
 }
 /**
  * Validate attribute value for attributes with source models
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $attrValue
  * @return array|bool
  */
 protected function _validateAttributeWithSource(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $attrValue)
 {
     $errors = array();
     // validate attributes with source models
     if (null !== $attrValue && $attribute->getSourceModel()) {
         if ('multiselect' !== $attribute->getFrontendInput() && is_array($attrValue)) {
             return array('Invalid value type for ' . $attribute->getAttributeCode());
         }
         $possibleValues = $attribute->getSource()->getAllOptions(false);
         foreach ((array) $attrValue as $value) {
             if (is_scalar($value)) {
                 $value = (string) $value;
                 $isValid = false;
                 foreach ($possibleValues as $optionData) {
                     // comparison without types check is performed only when both values are numeric
                     $useStrictMode = !(is_numeric($value) && is_numeric($optionData['value']));
                     $isValid = $useStrictMode ? $value === $optionData['value'] : $value == $optionData['value'];
                     if ($isValid) {
                         break;
                     }
                 }
                 if (!$isValid) {
                     $errors[] = 'Invalid value "' . $value . '" for ' . $attribute->getAttributeCode();
                 }
             } else {
                 $errors[] = 'Invalid value type for ' . $attribute->getAttributeCode();
             }
         }
     }
     return $errors ? $errors : true;
 }
Beispiel #7
0
 /**
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array|Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection $optionCollection
  * @return array
  */
 protected function _prepareOptionValues(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $optionCollection)
 {
     $type = $attribute->getFrontendInput();
     if ($type === 'select' || $type === 'multiselect') {
         $defaultValues = explode(',', $attribute->getDefaultValue());
         $inputType = $type === 'select' ? 'radio' : 'checkbox';
     } else {
         $defaultValues = array();
         $inputType = '';
     }
     $values = array();
     $isSystemAttribute = is_array($optionCollection);
     foreach ($optionCollection as $option) {
         $bunch = $isSystemAttribute ? $this->_prepareSystemAttributeOptionValues($option, $inputType, $defaultValues) : $this->_prepareUserDefinedAttributeOptionValues($option, $inputType, $defaultValues);
         foreach ($bunch as $value) {
             $values[] = new Varien_Object($value);
         }
     }
     return $values;
 }