protected function isAttributeAllowed(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->getFrontendLabel()) { return true; } return false; }
/** * 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->getAttributeCode() != 'tier_price') { return false; } return true; }
protected function isAttributeAllowed(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) { if ($attribute->isAllowedForRuleCondition() && $attribute->getDataUsingMethod($this->_isUsedForRuleProperty)) { return true; } } return false; }
public function setPricingLabelFromAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->getSource()) { $this->setLabel($attribute->getSource()->getOptionText($this->getValueIndex())); } else { $this->setLabel($this->getValueIndex()); } return $this; }
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; }
/** * @param Mage_Eav_Model_Entity_Type $object * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param mixed $value * @return $this * @throws Mage_Core_Exception */ protected function _saveAttribute($object, $attribute, $value) { $table = $attribute->getBackend()->getTable(); if (!isset($this->_attributeValuesToSave[$table])) { $this->_attributeValuesToSave[$table] = array(); } $entityIdField = $attribute->getBackend()->getEntityIdField(); $data = array('entity_type_id' => $object->getEntityTypeId(), $entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute)); $this->_attributeValuesToSave[$table][] = $data; $this->_saveEntityData($object); return $this; }
/** * Delete product data * * @param Mage_Catalog_Model_Product $product * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return Mage_Weee_Model_Resource_Attribute_Backend_Weee_Tax */ public function deleteProductData($product, $attribute) { $where = array('entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId()); $adapter = $this->_getWriteAdapter(); if (!$attribute->isScopeGlobal()) { $storeId = $product->getStoreId(); if ($storeId) { $where['website_id IN(?)'] = array(0, Mage::app()->getStore($storeId)->getWebsiteId()); } } $adapter->delete($this->getMainTable(), $where); return $this; }
public function callbackFilterPartsCompatibilityAttribute(Varien_Data_Collection_Db $collection, $column) { $value = $column->getFilter()->getValue(); if (is_null($value)) { return; } if (!$this->partsCompatibilityAttribute) { return; } if ($value == 1) { $attributeCode = $this->partsCompatibilityAttribute->getAttributeCode(); $collection->addFieldToFilter($attributeCode, array('notnull' => true)); $collection->addFieldToFilter($attributeCode, array('neq' => '')); $collection->addFieldToFilter('is_parts_compatibility_attribute_in_product_attribute_set', array('notnull' => true)); } else { $attributeId = $this->partsCompatibilityAttribute->getId(); $storeId = $this->getListing()->getStoreId(); $joinCondition = 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId; if (!$this->partsCompatibilityAttribute->isScopeGlobal()) { $joinCondition .= ' and eaa.store_id = ' . $storeId; } $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), $joinCondition, array('value')); $collection->getSelect()->orWhere('eaa.value IS NULL'); $collection->getSelect()->orWhere('eaa.value = \'\''); $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL'); } }
private function prepareExistingMotorsData() { $motorsHelper = Mage::helper('M2ePro/Component_Ebay_Motors'); $products = $this->getCollection()->getItems(); $productsMotorsData = array(); $items = array(); $filters = array(); $groups = array(); foreach ($products as $product) { if (!$product->getData('is_motors_attribute_in_product_attribute_set')) { continue; } $productId = $product->getData('listing_product_id'); $attributeCode = $this->motorsAttribute->getAttributeCode(); $attributeValue = $product->getData($attributeCode); $productsMotorsData[$productId] = $motorsHelper->parseAttributeValue($attributeValue); $items = array_merge($items, array_keys($productsMotorsData[$productId]['items'])); $filters = array_merge($filters, $productsMotorsData[$productId]['filters']); $groups = array_merge($groups, $productsMotorsData[$productId]['groups']); } //------------------------------- $typeIdentifier = $motorsHelper->getIdentifierKey($this->getMotorsType()); $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($motorsHelper->getDictionaryTable($this->getMotorsType()), array($typeIdentifier))->where('`' . $typeIdentifier . '` IN (?)', $items); $existedItems = $select->query()->fetchAll(PDO::FETCH_COLUMN); //------------------------------- //------------------------------- $filtersTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_filter'); $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($filtersTable, array('id'))->where('`id` IN (?)', $filters); $existedFilters = $select->query()->fetchAll(PDO::FETCH_COLUMN); //------------------------------- //------------------------------- $groupsTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_group'); $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($groupsTable, array('id'))->where('`id` IN (?)', $groups); $existedGroups = $select->query()->fetchAll(PDO::FETCH_COLUMN); //------------------------------- foreach ($productsMotorsData as $productId => $productMotorsData) { foreach ($productMotorsData['items'] as $item => $itemData) { if (!in_array($item, $existedItems)) { unset($productsMotorsData[$productId]['items'][$item]); } } foreach ($productMotorsData['filters'] as $key => $filterId) { if (!in_array($filterId, $existedFilters)) { unset($productsMotorsData[$productId]['filters'][$key]); } } foreach ($productMotorsData['groups'] as $key => $groupId) { if (!in_array($groupId, $existedGroups)) { unset($productsMotorsData[$productId]['groups'][$key]); } } } $this->productsMotorsData = $productsMotorsData; return $this; }
/** * Retrieve Select for update Flat data * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param int $store * @param bool $hasValueField flag which require option value * @return Varien_Db_Select */ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true) { $attributeTable = $attribute->getBackend()->getTable(); $attributeCode = $attribute->getAttributeCode(); $joinCondition = "`e`.`entity_id`=`t1`.`entity_id`"; if ($attribute->getFlatAddChildData()) { $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`"; } $valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)"); $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), "`t2`.`entity_id`=`t1`.`entity_id`" . " AND `t1`.`entity_type_id`=`t2`.`entity_type_id`" . " AND `t1`.`attribute_id`=`t2`.`attribute_id`" . " AND `t2`.`store_id`={$store}", array($attributeCode => $valueExpr)); if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) { $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)")); } $select->where('t1.entity_type_id=?', $attribute->getEntityTypeId())->where('t1.attribute_id=?', $attribute->getId())->where('t1.store_id=?', 0); if ($attribute->getFlatAddChildData()) { $select->where("e.is_child=?", 0); } return $select; }
public function callbackFilterMotorsSpecificsAttribute(Varien_Data_Collection_Db $collection, $column) { $value = $column->getFilter()->getValue(); if ($value == null) { return; } if (!$this->motorsSpecificsAttribute) { return; } $attributeCode = $this->motorsSpecificsAttribute->getAttributeCode(); if ($value == 1) { $collection->addFieldToFilter($attributeCode, array('notnull' => true)); $collection->addFieldToFilter($attributeCode, array('neq' => '\'\'')); $collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true)); } else { $collection->addFieldToFilter(array(array('attribute' => $attributeCode, 'null' => true), array('attribute' => $attributeCode, 'eq' => '\'\''), array('attribute' => 'is_motors_attribute_in_product_attribute_set', 'null' => true))); } }
/** * Retrieve Select for update Flat data * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param int $store * @param bool $hasValueField flag which require option value * @return Varien_Db_Select */ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true) { $adapter = $this->_getReadAdapter(); $attributeTable = $attribute->getBackend()->getTable(); $attributeCode = $attribute->getAttributeCode(); $joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d"; $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID); if ($attribute->getFlatAddChildData()) { $joinCondition .= ' AND e.child_id = t1.entity_id'; } $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value'); /** @var $select Varien_Db_Select */ $select = $adapter->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr)); if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) { $valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value'); $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "to1.option_id = {$valueExpr} AND to1.store_id = 0", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), array($attributeCode . '_value' => $valueIdExpr)); } if ($attribute->getFlatAddChildData()) { $select->where('e.is_child = 0'); } return $select; }
/** * Insert or Update attribute data * * @param Mage_Catalog_Model_Abstract $object * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param mixed $value * @return Mage_Catalog_Model_Resource_Abstract */ protected function _saveAttributeValue($object, $attribute, $value) { $write = $this->_getWriteAdapter(); //set default store id $storeId = Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID; $table = $attribute->getBackend()->getTable(); /** * If we work in single store mode all values should be saved just * for default store id * In this case we clear all not default values */ if (Mage::app()->isSingleStoreMode()) { $storeId = $this->getDefaultStoreId(); $write->delete($table, array('attribute_id = ?' => $attribute->getAttributeId(), 'entity_id = ?' => $object->getEntityId(), 'store_id <> ?' => $storeId)); } $data = new Varien_Object(array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getAttributeId(), 'store_id' => $storeId, 'entity_id' => $object->getEntityId(), 'value' => $this->_prepareValueForSave($value, $attribute))); $bind = $this->_prepareDataForTable($data, $table); if ($attribute->isScopeStore()) { /** * Update attribute value for store */ $this->_attributeValuesToSave[$table][] = $bind; } else { if ($attribute->isScopeWebsite() && $storeId != $this->getDefaultStoreId()) { /** * Update attribute value for website */ $storeIds = Mage::app()->getStore($storeId)->getWebsite()->getStoreIds(true); foreach ($storeIds as $storeId) { $bind['store_id'] = (int) $storeId; $this->_attributeValuesToSave[$table][] = $bind; } } else { /** * Update global attribute value */ $bind['store_id'] = $this->getDefaultStoreId(); $this->_attributeValuesToSave[$table][] = $bind; } } return $this; }
/** * 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() != ""; }
/** * Build date element html string for attribute * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param string $part * @return string */ public function getDateInput($attribute, $part = 'from') { $name = $attribute->getAttributeCode() . '[' . $part . ']'; $value = $this->getAttributeValue($attribute, $part); return $this->_getDateBlock()->setName($name)->setId($attribute->getAttributeCode() . ($part == 'from' ? '' : '_' . $part))->setTitle($this->getAttributeLabel($attribute))->setValue($value)->setImage($this->getSkinUrl('images/calendar.gif'))->setFormat('%m/%d/%y')->setClass('input-text')->getHtml(); }
/** * 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); }
/** * 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(); } }
/** * get elasticsearch field mapping * * @param $attribute Mage_Eav_Model_Entity_Attribute_Abstract * @param $fieldType * @return array */ protected function _getFieldMapping(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $fieldType, $fieldName) { switch ($fieldType) { case 'date': $mapping['type'] = 'date'; $mapping['format'] = 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd'; break; case 'string': //@todo add backend flags for analyzers and so on if (1 == $attribute->getisSearchable() || 1 == $attribute->getisVisibleInAdvancedSearch()) { $mapping = array('type' => 'multi_field', 'fields' => array($fieldName => array("store" => 'no', 'type' => 'string', 'boost' => $attribute->getSearchWeight()), 'untouched' => array('type' => 'string', 'index' => 'not_analyzed'))); //for now we implementing all analyzer //@todo make multiselect in backend to make analyser selectable $settings = $this->_getIndexSettings(); foreach (array_keys($settings['analysis']['analyzer']) as $analyzer) { $mapping['fields'][$analyzer] = array('type' => 'string', 'analyzer' => $analyzer, 'boost' => $attribute->getSearchWeight()); } } else { $mapping = array('type' => 'string', 'index' => 'not_analyzed'); } break; default: $mapping = array('type' => $fieldType); break; } return $mapping; }
/** * Check whether the attribute is a real field in entity table * Rewrited for EAV Collection * * @param integer|string|Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return bool */ public function isAttributeStatic($attribute) { $attributeCode = null; if ($attribute instanceof Mage_Eav_Model_Entity_Attribute_Interface) { $attributeCode = $attribute->getAttributeCode(); } elseif (is_string($attribute)) { $attributeCode = $attribute; } elseif (is_numeric($attribute)) { $attributeCode = $this->getAttribute($attribute)->getAttributeCode(); } if ($attributeCode) { $columns = $this->getAllTableColumns(); if (in_array($attributeCode, $columns)) { return true; } } return false; }
/** * 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; }
/** * Save additional data * * @return Mage_Eav_Model_Entity_Attribute */ protected function _afterSave() { $this->_getResource()->saveInSetIncluding($this); return parent::_afterSave(); }
/** * Retrieve Select For Flat Attribute update * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param int $storeId * @return Varien_Db_Select */ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId) { $adapter = $this->_getReadAdapter(); $joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d"; $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID); if ($attribute->getFlatAddChildData()) { $joinCondition .= ' AND e.child_id = t1.entity_id'; } $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value'); /** @var $select Varien_Db_Select */ $select = $adapter->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), array($attribute->getAttributeCode() => $valueExpr)); if ($attribute->getFlatAddChildData()) { $select->where("e.is_child = ?", 0); } return $select; }
/** * Retrieve Select For Flat Attribute update * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param int $store * @return Varien_Db_Select */ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store) { $joinCondition = "`e`.`entity_id`=`t1`.`entity_id`"; if ($attribute->getFlatAddChildData()) { $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`"; } $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), "t2.entity_id = t1.entity_id" . " AND t1.entity_type_id = t2.entity_type_id" . " AND t1.attribute_id = t2.attribute_id" . " AND t2.store_id = {$store}", array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"))->where("t1.entity_type_id=?", $attribute->getEntityTypeId())->where("t1.attribute_id=?", $attribute->getId())->where("t1.store_id=?", 0); if ($attribute->getFlatAddChildData()) { $select->where("e.is_child=?", 0); } return $select; }
/** * Check is attribute value empty * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param mixed $value * @return bool */ protected function _isAttributeValueEmpty(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $value) { return $attribute->isValueEmpty($value); }
/** * Prepare value for save * * @param mixed $value * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return mixed */ protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { $type = $attribute->getBackendType(); if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') { return null; } if ($type == 'decimal') { return Mage::app()->getLocale()->getNumber($value); } return $value; }
/** * 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; }
/** * Check if attribute is allowed * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @param array $attributes * @return boolean */ protected function _isAllowedAttribute($attribute, $attributes = null) { $isAllowed = true; if (is_array($attributes) && !(in_array($attribute->getAttributeCode(), $attributes) || in_array($attribute->getAttributeId(), $attributes))) { $isAllowed = false; } return $isAllowed; }
/** * Prepare value for save * * @param mixed $value * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return mixed */ protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { $type = $attribute->getBackendType(); if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') { $value = null; } return parent::_prepareValueForSave($value, $attribute); }
/** * Prepare value for save * * @param mixed $value * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return mixed */ protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->getBackendType() == 'decimal') { return Mage::app()->getLocale()->getNumber($value); } return $value; }