Esempio n. 1
0
 /**
  * Actions after save
  *
  * @return $this
  */
 protected function _afterSave()
 {
     $result = parent::_afterSave();
     $valueConfig = array('' => array('is_required' => 0, 'is_visible' => 0), 'opt' => array('is_required' => 0, 'is_visible' => 1), '1' => array('is_required' => 0, 'is_visible' => 1), 'req' => array('is_required' => 1, 'is_visible' => 1));
     $value = $this->getValue();
     if (isset($valueConfig[$value])) {
         $data = $valueConfig[$value];
     } else {
         $data = $valueConfig[''];
     }
     if ($this->getScope() == 'websites') {
         $website = $this->storeManager->getWebsite($this->getScopeCode());
         $dataFieldPrefix = 'scope_';
     } else {
         $website = null;
         $dataFieldPrefix = '';
     }
     foreach ($this->_getAttributeObjects() as $attributeObject) {
         if ($website) {
             $attributeObject->setWebsite($website);
             $attributeObject->load($attributeObject->getId());
         }
         $attributeObject->setData($dataFieldPrefix . 'is_required', $data['is_required']);
         $attributeObject->setData($dataFieldPrefix . 'is_visible', $data['is_visible']);
         $attributeObject->save();
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Prepare and store cron settings after save
  *
  * @return \Magento\Tax\Model\Config\Notification
  */
 protected function _afterSave()
 {
     if ($this->isValueChanged()) {
         $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT);
         $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY);
     }
     return parent::_afterSave($this);
 }
Esempio n. 3
0
 /**
  * Cron settings after save
  *
  * @return $this
  */
 protected function _afterSave()
 {
     $cronExprString = '';
     $time = explode(',', $this->_configValueFactory->create()->load('paypal/fetch_reports/time', 'path')->getValue());
     if ($this->_configValueFactory->create()->load('paypal/fetch_reports/active', 'path')->getValue()) {
         $interval = $this->_configValueFactory->create()->load(self::CRON_MODEL_PATH_INTERVAL, 'path')->getValue();
         $cronExprString = "{$time[1]} {$time[0]} */{$interval} * *";
     }
     $this->_configValueFactory->create()->load(self::CRON_STRING_PATH, 'path')->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save();
     return parent::_afterSave();
 }
Esempio n. 4
0
 /**
  * Update the default product tax class
  *
  * @return \Magento\Tax\Model\Config\TaxClass
  */
 protected function _afterSave()
 {
     $attributeCode = "tax_class_id";
     $attribute = $this->attributeFactory->create();
     $attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, $attributeCode);
     if (!$attribute->getId()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Invalid attribute %1', $attributeCode));
     }
     $attribute->setData("default_value", $this->getData('value'));
     $attribute->save();
     return parent::_afterSave($this);
 }
Esempio n. 5
0
 /**
  * @return void
  */
 public function _afterSave()
 {
     parent::_afterSave();
     $this->_cacheManager->clean(array('checkout_quote'));
 }
Esempio n. 6
0
 /**
  * Check and process robots file
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::_afterSave();
 }