/**
  * Toggle cache
  *
  */
 public function execute()
 {
     $allTypes = array_keys($this->_cacheTypeList->getTypes());
     $updatedTypes = 0;
     $disable = true;
     $enable = true;
     foreach ($allTypes as $code) {
         if ($this->_cacheState->isEnabled($code) && $disable) {
             $this->_cacheState->setEnabled($code, false);
             $updatedTypes++;
             $enable = false;
         }
         if (!$this->_cacheState->isEnabled($code) && $enable) {
             $this->_cacheState->setEnabled($code, true);
             $updatedTypes++;
             $disable = false;
         }
         if ($disable) {
             $this->_cacheTypeList->cleanType($code);
         }
     }
     if ($updatedTypes > 0) {
         $this->_cacheState->persist();
         $this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function install(array $fixtures)
 {
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
     $adapter = $this->resource->getConnection('core_write');
     $regions = $this->loadDirectoryRegions();
     foreach ($fixtures as $fileName) {
         $fileName = $this->fixtureManager->getFixture($fileName);
         if (!file_exists($fileName)) {
             continue;
         }
         $rows = $this->csvReader->getData($fileName);
         $header = array_shift($rows);
         foreach ($rows as $row) {
             $data = [];
             foreach ($row as $key => $value) {
                 $data[$header[$key]] = $value;
             }
             $regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
             try {
                 $adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsite()->getId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
             } catch (\Zend_Db_Statement_Exception $e) {
                 if ($e->getCode() == self::ERROR_CODE_DUPLICATE_ENTRY) {
                     // In case if Sample data was already installed we just skip duplicated records installation
                     continue;
                 } else {
                     throw $e;
                 }
             }
         }
     }
     $this->configWriter->save('carriers/tablerate/active', 1);
     $this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
     $this->cacheTypeList->cleanType('config');
 }
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing Tablerate:');
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
     $connection = $this->resource->getConnection('core');
     $fixtureFile = 'OfflineShipping/tablerate.csv';
     $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
     $regions = $this->loadDirectoryRegions();
     /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
     $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
     foreach ($csvReader as $data) {
         $regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
         try {
             $connection->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsiteId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
         } catch (\Zend_Db_Statement_Exception $e) {
             if ($e->getCode() == self::ERROR_CODE_DUPLICATE_ENTRY) {
                 // In case if Sample data was already installed we just skip duplicated records installation
                 continue;
             } else {
                 throw $e;
             }
         }
         $this->logger->logInline('.');
     }
     $this->configWriter->save('carriers/tablerate/active', 1);
     $this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
     $this->cacheTypeList->cleanType('config');
 }
 /**
  * Set tax ignore notification flag and redirect back
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function execute()
 {
     $section = $this->getRequest()->getParam('section');
     if ($section) {
         try {
             $path = 'tax/notification/ignore_' . $section;
             $this->_objectManager->get('Magento\\Config\\Model\\Resource\\Config')->saveConfig($path, 1, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, 0);
         } catch (\Exception $e) {
             $this->messageManager->addError($e->getMessage());
         }
     }
     // clear the block html cache
     $this->_cacheTypeList->cleanType('block_html');
     $this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
     $this->getResponse()->setRedirect($this->_redirect->getRefererUrl());
 }
 /**
  * Set tax ignore notification flag and redirect back
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     try {
         $path = \ClassyLlama\AvaTax\Helper\Config::XML_PATH_AVATAX_ADMIN_NOTIFICATION_IGNORE_NATIVE_TAX_RULES;
         $this->_objectManager->get('Magento\\Config\\Model\\ResourceModel\\Config')->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
         $this->messageManager->addSuccess('Notification successfully ignored');
     } catch (\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     }
     // clear the block html cache
     $this->cacheTypeList->cleanType('config');
     $this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setRefererUrl();
 }
예제 #6
0
 /**
  * Set tax ignore notification flag and redirect back
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $section = $this->getRequest()->getParam('section');
     if ($section) {
         try {
             $path = 'tax/notification/ignore_' . $section;
             $this->_objectManager->get('Magento\\Config\\Model\\ResourceModel\\Config')->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
         } catch (\Exception $e) {
             $this->messageManager->addError($e->getMessage());
         }
     }
     // clear the block html cache
     $this->_cacheTypeList->cleanType('block_html');
     $this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'block_html']);
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setRefererUrl();
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing Tablerate:');
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
     $adapter = $this->resource->getConnection('core_write');
     $fixtureFile = 'OfflineShipping/tablerate.csv';
     $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
     $regions = $this->loadDirectoryRegions();
     /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
     $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
     foreach ($csvReader as $data) {
         $regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
         $adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsiteId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
         $this->logger->logInline('.');
     }
     $this->configWriter->save('carriers/tablerate/active', 1);
     $this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
     $this->cacheTypeList->cleanType('config');
 }
예제 #8
0
 /**
  * Cleans up caches
  *
  * @param array $types
  * @return void
  */
 public function clean(array $types)
 {
     foreach ($types as $type) {
         $this->cacheTypeList->cleanType($type);
     }
 }