Esempio n. 1
0
 /**
  * Processing object before save data
  *
  * @return \Magento\Framework\Model\AbstractModel
  * @throws \Magento\Eav\Exception
  */
 public function beforeSave()
 {
     try {
         $this->attrLockValidator->validate($this);
     } catch (\Magento\Framework\Exception\LocalizedException $exception) {
         throw new \Magento\Eav\Exception(__($exception->getMessage()));
     }
     $this->setData('modulePrefix', self::MODULE_NAME);
     return parent::beforeSave();
 }
Esempio n. 2
0
 /**
  * Processing object before save data
  *
  * @return \Magento\Framework\Model\AbstractModel
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function beforeSave()
 {
     $this->setData('modulePrefix', self::MODULE_NAME);
     if (isset($this->_origData[self::KEY_IS_GLOBAL])) {
         if (!isset($this->_data[self::KEY_IS_GLOBAL])) {
             $this->_data[self::KEY_IS_GLOBAL] = self::SCOPE_GLOBAL;
         }
         if ($this->_data[self::KEY_IS_GLOBAL] != $this->_origData[self::KEY_IS_GLOBAL]) {
             try {
                 $this->attrLockValidator->validate($this);
             } catch (\Magento\Framework\Exception\LocalizedException $exception) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Do not change the scope. %1', $exception->getMessage()));
             }
         }
     }
     if ($this->getFrontendInput() == 'price') {
         if (!$this->getBackendModel()) {
             $this->setBackendModel('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price');
         }
     }
     if ($this->getFrontendInput() == 'textarea') {
         if ($this->getIsWysiwygEnabled()) {
             $this->setIsHtmlAllowedOnFront(1);
         }
     }
     if (!$this->getIsSearchable()) {
         $this->setIsVisibleInAdvancedSearch(false);
     }
     return parent::beforeSave();
 }