当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave怎么用?PHP Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Attribute_Abstract的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeSave

 protected function _beforeSave()
 {
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('eav/entity_attribute_frontend_datetime');
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_media');
         }
     }
     if ($this->getFrontendInput() == 'price') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('catalog/product_attribute_backend_price');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:22,代码来源:Attribute.php

示例2: _beforeSave

 /**
  * Prepare data for save
  *
  * @return Mage_Eav_Model_Entity_Attribute
  * @throws Mage_Eav_Exception
  */
 protected function _beforeSave()
 {
     /**
      * Check for maximum attribute_code length
      */
     if (isset($this->_data['attribute_code']) && !Zend_Validate::is($this->_data['attribute_code'], 'StringLength', array('max' => self::ATTRIBUTE_CODE_MAX_LENGTH))) {
         throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Maximum length of attribute code must be less then %s symbols', self::ATTRIBUTE_CODE_MAX_LENGTH));
     }
     $defaultValue = $this->getDefaultValue();
     $hasDefaultValue = (string) $defaultValue != '';
     if ($this->getBackendType() == 'decimal' && $hasDefaultValue) {
         $locale = Mage::app()->getLocale()->getLocaleCode();
         if (!Zend_Locale_Format::isNumber($defaultValue, array('locale' => $locale))) {
             throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid default decimal value'));
         }
         try {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $this->setDefaultValue($filter->filter($defaultValue));
         } catch (Exception $e) {
             throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid default decimal value'));
         }
     }
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('eav/entity_attribute_frontend_datetime');
         }
         // save default date value as timestamp
         if ($hasDefaultValue) {
             $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             try {
                 $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue();
                 $this->setDefaultValue($defaultValue);
             } catch (Exception $e) {
                 throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid default date'));
             }
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_media');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:53,代码来源:Attribute.php

示例3: _beforeSave

 /**
  * Prepare data for save
  *
  * @return Mage_Eav_Model_Entity_Attribute
  */
 protected function _beforeSave()
 {
     // prevent overriding product data
     if (isset($this->_data['attribute_code']) && Mage::getModel('Mage_Catalog_Model_Product')->isReservedAttribute($this)) {
         throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('The attribute code \'%s\' is reserved by system. Please try another attribute code', $this->_data['attribute_code']));
     }
     /**
      * Check for maximum attribute_code length
      */
     if (isset($this->_data['attribute_code']) && !Zend_Validate::is($this->_data['attribute_code'], 'StringLength', array('max' => self::ATTRIBUTE_CODE_MAX_LENGTH))) {
         throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Maximum length of attribute code must be less then %s symbols', self::ATTRIBUTE_CODE_MAX_LENGTH));
     }
     $defaultValue = $this->getDefaultValue();
     $hasDefaultValue = (string) $defaultValue != '';
     if ($this->getBackendType() == 'decimal' && $hasDefaultValue) {
         if (!Zend_Locale_Format::isNumber($defaultValue, array('locale' => Mage::app()->getLocale()->getLocaleCode()))) {
             throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value'));
         }
         try {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $this->setDefaultValue($filter->filter($defaultValue));
         } catch (Exception $e) {
             throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default decimal value'));
         }
     }
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('Mage_Eav_Model_Entity_Attribute_Frontend_Datetime');
         }
         // save default date value as timestamp
         if ($hasDefaultValue) {
             $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             try {
                 $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue();
                 $this->setDefaultValue($defaultValue);
             } catch (Exception $e) {
                 throw Mage::exception('Mage_Eav', Mage::helper('Mage_Eav_Helper_Data')->__('Invalid default date'));
             }
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('Mage_Eav_Model_Entity_Attribute_Backend_Default');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:natxetee,项目名称:magento2,代码行数:55,代码来源:Attribute.php

示例4: _beforeSave

 protected function _beforeSave()
 {
     // prevent overriding product data
     if (isset($this->_data['attribute_code']) && AO::getModel('catalog/product')->isReservedAttribute($this)) {
         AO::throwException(AO::helper('eav')->__('The attribute code \'%s\' is reserved by system. Please, try another attribute code.', $this->_data['attribute_code']));
     }
     // prevent changing attribute scope, if used in configurable products
     if (isset($this->_origData['is_global'])) {
         if (!isset($this->_data['is_global'])) {
             AO::throwException('0_o');
         }
         if ($this->_data['is_global'] != $this->_origData['is_global'] && $this->_getResource()->isUsedBySuperProducts($this)) {
             AO::throwException(AO::helper('eav')->__('Scope must not be changed, because the attribute is used in configurable products.'));
         }
     }
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('eav/entity_attribute_frontend_datetime');
         }
         // save default date value as timestamp
         if ($defaultValue = $this->getDefaultValue()) {
             $format = AO::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             $this->setDefaultValue(AO::app()->getLocale()->date($defaultValue, $format, null, false)->toValue());
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_media');
         }
     }
     if ($this->getFrontendInput() == 'price') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('catalog/product_attribute_backend_price');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:40,代码来源:Entity_Attribute.php

示例5: _beforeSave

 protected function _beforeSave()
 {
     // prevent overriding product data
     if (isset($this->_data['attribute_code']) && Mage::getModel('catalog/product')->isReservedAttribute($this)) {
         Mage::throwException(Mage::helper('eav')->__('The attribute code \'%s\' is reserved by system. Please try another attribute code.', $this->_data['attribute_code']));
     }
     $defaultValue = $this->getDefaultValue();
     $hasDefaultValue = (string) $defaultValue != '';
     if ($this->getBackendType() == 'decimal' && $hasDefaultValue) {
         if (!Zend_Locale_Format::isNumber($defaultValue, array('locale' => Mage::app()->getLocale()->getLocaleCode()))) {
             throw new Exception('Invalid default decimal value.');
         }
         try {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $this->setDefaultValue($filter->filter($defaultValue));
         } catch (Exception $e) {
             throw new Exception('Invalid default decimal value.');
         }
     }
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('eav/entity_attribute_frontend_datetime');
         }
         // save default date value as timestamp
         if ($hasDefaultValue) {
             $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             try {
                 $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue();
                 $this->setDefaultValue($defaultValue);
             } catch (Exception $e) {
                 throw new Exception('Invalid default date.');
             }
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_media');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:44,代码来源:Attribute.php

示例6: _beforeSave

 protected function _beforeSave()
 {
     // prevent overriding product data
     if (isset($this->_data['attribute_code']) && Mage::getModel('catalog/product')->isReservedAttribute($this)) {
         Mage::throwException(Mage::helper('eav')->__('The attribute code \'%s\' is reserved by system. Please, try another attribute code.', $this->_data['attribute_code']));
     }
     if ($this->getBackendType() == 'datetime') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_datetime');
         }
         if (!$this->getFrontendModel()) {
             $this->setFrontendModel('eav/entity_attribute_frontend_datetime');
         }
         // save default date value as timestamp
         if ($defaultValue = $this->getDefaultValue()) {
             $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
             try {
                 $defaultValue = Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue();
                 $this->setDefaultValue($defaultValue);
             } catch (Exception $e) {
                 throw new Exception("Invalid default date.");
             }
         }
     }
     if ($this->getBackendType() == 'gallery') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('eav/entity_attribute_backend_media');
         }
     }
     return parent::_beforeSave();
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:31,代码来源:Attribute.php


注:本文中的Mage_Eav_Model_Entity_Attribute_Abstract::_beforeSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。