/** * Actions after save * * @return $this */ public function afterSave() { $result = parent::afterSave(); $valueConfig = ['' => ['is_required' => 0, 'is_visible' => 0], 'opt' => ['is_required' => 0, 'is_visible' => 1], '1' => ['is_required' => 0, 'is_visible' => 1], 'req' => ['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; }
/** * @return \Magento\Framework\Model\AbstractModel|void */ public function afterSave() { /** @var \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate $matrixRate */ $matrixRate = $this->_matrixrateFactory->create(); $matrixRate->uploadAndImport($this); return parent::afterSave(); }
/** * Check and process robots file * * @return $this */ public function afterSave() { if ($this->getValue()) { $this->_directory->writeFile($this->_file, $this->getValue()); } return parent::afterSave(); }
/** * @param int $callNumber * @param string $oldValue * @dataProvider afterSaveDataProvider */ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate'); $this->configMock->expects($this->any())->method('getValue')->willReturn($oldValue); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); }
/** * Cron settings after save * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() { $enabled = $this->getData('groups/log/fields/enabled/value'); $time = $this->getData('groups/log/fields/time/value'); $frequency = $this->getData('groups/log/fields/frequency/value'); $frequencyWeekly = \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY; $frequencyMonthly = \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY; if ($enabled) { $cronExprArray = [intval($time[1]), intval($time[0]), $frequency == $frequencyMonthly ? '1' : '*', '*', $frequency == $frequencyWeekly ? '1' : '*']; $cronExprString = join(' ', $cronExprArray); } else { $cronExprString = ''; } try { /** @var $configValue \Magento\Framework\App\Config\ValueInterface */ $configValue = $this->_configValueFactory->create(); $configValue->load(self::CRON_STRING_PATH, 'path'); $configValue->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save(); /** @var $configValue \Magento\Framework\App\Config\ValueInterface */ $configValue = $this->_configValueFactory->create(); $configValue->load(self::CRON_MODEL_PATH, 'path'); $configValue->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save(); } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.')); } return parent::afterSave(); }
/** * @return $this */ public function afterSave() { if ($this->isValueChanged()) { $this->updateSuffixForUrlRewrites(); } return parent::afterSave(); }
/** * Invalidate cache type, when value was changed * * @return $this */ public function afterSave() { if ($this->isValueChanged()) { $this->cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP); } return parent::afterSave(); }
/** * Clean compiled JS/CSS when updating configuration settings * * @return $this */ public function afterSave() { if ($this->isValueChanged()) { $this->_mergeService->cleanMergedJsCss(); } return parent::afterSave(); }
/** * @return $this */ public function afterSave() { /** @var \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate $tableRate */ $tableRate = $this->_tablerateFactory->create(); $tableRate->uploadAndImport($this); return parent::afterSave(); }
/** * Prepare and store cron settings after save * * @return $this */ public 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(); }
/** * Save EAV default value after save * * @return $this */ public function afterSave() { $result = parent::afterSave(); $attributeObject = $this->eavConfig->getAttribute('customer', 'disable_auto_group_change'); $attributeObject->setData('default_value', $this->getValue()); $attributeObject->save(); return $result; }
/** * After save call * Invalidate catalog search index if engine was changed * * @return $this */ public function afterSave() { parent::afterSave(); if ($this->isValueChanged()) { $this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)->invalidate(); } return $this; }
/** * Set status 'invalidate' for blocks and other output caches * * @return $this */ public function afterSave() { $types = array_keys($this->_config->getValue(self::XML_PATH_INVALID_CACHES, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); if ($this->isValueChanged()) { $this->cacheTypeList->invalidate($types); } return parent::afterSave(); }
/** * Delete custom admin url from configuration if "Use Custom Admin Url" option disabled * * @return $this */ public function afterSave() { $value = $this->getValue(); if (!$value) { $this->_configWriter->delete(Custom::XML_PATH_SECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID); $this->_configWriter->delete(Custom::XML_PATH_UNSECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID); } return parent::afterSave(); }
/** * Cron settings after save * * @return $this */ public 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(); }
/** * Update the default product tax class * * @return $this */ public 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(); }
/** * @return $this * @throws \Exception */ public function afterSave() { $time = $this->getData('groups/generate/fields/time/value'); $frequency = $this->getData('groups/generate/fields/frequency/value'); $cronExprArray = [intval($time[1]), intval($time[0]), $frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', '*', $frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*']; $cronExprString = join(' ', $cronExprArray); try { $this->_configValueFactory->create()->load(self::CRON_STRING_PATH, 'path')->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save(); $this->_configValueFactory->create()->load(self::CRON_MODEL_PATH, 'path')->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save(); } catch (\Exception $e) { throw new \Exception(__('We can\'t save the cron expression.')); } return parent::afterSave(); }
/** * {@inheritdoc} */ public function afterSave() { if ($this->getScope() == 'stores') { $rootId = $this->getValue(); $storeId = $this->getScopeId(); $tree = $this->_catalogCategory->getTreeModel(); // Create copy of categories attributes for choosed store $tree->load(); $root = $tree->getNodeById($rootId); // Save root $this->_catalogCategory->setStoreId(0)->load($root->getId()); $this->_catalogCategory->setStoreId($storeId)->save(); foreach ($root->getAllChildNodes() as $node) { $this->_catalogCategory->setStoreId(0)->load($node->getId()); $this->_catalogCategory->setStoreId($storeId)->save(); } } return parent::afterSave(); }
/** * Cron settings after save * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() { $active = $this->getData(self::XML_PATH_BAIDUPING_ACTIVE); $frequency = (int) $this->getData(self::XML_PATH_BAIDUPING_FREQUENCY); if ($frequency >= 60 || $frequency <= 0) { $frequency = 15; } if ($active) { $cronExprArray = ['*/' . $frequency, '*', '*', '*', '*']; $cronExprString = join(' ', $cronExprArray); } else { $cronExprString = ''; } try { $this->_configValueFactory->create()->load(self::CRON_STRING_PATH, 'path')->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save(); } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.')); } return parent::afterSave(); }
/** * Actions after save * * @return $this */ public function afterSave() { $attribute = $this->_eavConfig->getAttribute('customer_address', 'street'); $value = $this->getValue(); switch ($this->getScope()) { case \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES: $website = $this->_storeManager->getWebsite($this->getScopeCode()); $attribute->setWebsite($website); $attribute->load($attribute->getId()); if ($attribute->getData('multiline_count') != $value) { $attribute->setData('scope_multiline_count', $value); } break; case ScopeConfigInterface::SCOPE_TYPE_DEFAULT: $attribute->setData('multiline_count', $value); break; } $attribute->save(); return parent::afterSave(); }
/** * Cron settings after save * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() { $enabled = $this->getData(self::XML_PATH_BACKUP_ENABLED); $time = $this->getData(self::XML_PATH_BACKUP_TIME); $frequency = $this->getData(self::XML_PATH_BACKUP_FREQUENCY); $frequencyWeekly = \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY; $frequencyMonthly = \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY; if ($enabled) { $cronExprArray = [intval($time[1]), intval($time[0]), $frequency == $frequencyMonthly ? '1' : '*', '*', $frequency == $frequencyWeekly ? '1' : '*']; $cronExprString = join(' ', $cronExprArray); } else { $cronExprString = ''; } try { $this->_configValueFactory->create()->load(self::CRON_STRING_PATH, 'path')->setValue($cronExprString)->setPath(self::CRON_STRING_PATH)->save(); $this->_configValueFactory->create()->load(self::CRON_MODEL_PATH, 'path')->setValue($this->_runModelPath)->setPath(self::CRON_MODEL_PATH)->save(); } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.')); } return parent::afterSave(); }
/** * Create db structure * * @return $this */ public function afterSave() { $helper = $this->_coreFileStorage; $helper->getStorageModel(null, ['init' => true]); return parent::afterSave(); }
/** * Clean compiled JS/CSS when updating url configuration settings * * @return $this */ public function afterSave() { if ($this->isValueChanged()) { switch ($this->getPath()) { case \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL: case \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL: case \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL: case \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL: $this->_mergeService->cleanMergedJsCss(); break; } } return parent::afterSave(); }
/** * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() { /** @var $collection \Magento\Config\Model\ResourceModel\Config\Data\Collection */ $collection = $this->_configsFactory->create(); $collection->addPathFilter('currency/options'); $values = explode(',', $this->getValue()); $exceptions = []; foreach ($collection as $data) { $match = false; $scopeName = __('Default scope'); if (preg_match('/(base|default)$/', $data->getPath(), $match)) { if (!in_array($data->getValue(), $values)) { $currencyName = $this->_localeCurrency->getCurrency($data->getValue())->getName(); if ($match[1] == 'base') { $fieldName = __('Base currency'); } else { $fieldName = __('Display default currency'); } switch ($data->getScope()) { case ScopeConfigInterface::SCOPE_TYPE_DEFAULT: $scopeName = __('Default scope'); break; case \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE: /** @var $website \Magento\Store\Model\Website */ $website = $this->_websiteFactory->create(); $websiteName = $website->load($data->getScopeId())->getName(); $scopeName = __('website(%1) scope', $websiteName); break; case \Magento\Store\Model\ScopeInterface::SCOPE_STORE: /** @var $store \Magento\Store\Model\Store */ $store = $this->_storeFactory->create(); $storeName = $store->load($data->getScopeId())->getName(); $scopeName = __('store(%1) scope', $storeName); break; } $exceptions[] = __('Currency "%1" is used as %2 in %3.', $currencyName, $fieldName, $scopeName); } } } if ($exceptions) { throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions))); } return parent::afterSave(); }
/** * @return void */ public function afterSave() { parent::afterSave(); $this->_cacheManager->clean(['checkout_quote']); }
/** * @return $this */ public function afterSave() { $result = parent::afterSave(); $this->_cacheManager->clean(['checkout_quote']); return $result; }
/** * Set after commit callback * * @return $this */ public function afterSave() { $this->_getResource()->addCommitCallback([$this, 'processValue']); return parent::afterSave(); }
/** * {@inheritdoc} * * {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches * * @return $this */ public function afterSave() { $this->invalidateCache(); return parent::afterSave(); }
/** * @return $this */ public function afterSave() { $this->_mutableConfig->setValue(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL, $this->getValue(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $this->_cacheManager->clean(); return parent::afterSave(); }
/** * @return $this */ public function afterSave() { $this->_backendUrl->renewSecretUrls(); return parent::afterSave(); }