Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed May 22, 2019
1 parent af13800 commit 90a9ab6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
11 changes: 7 additions & 4 deletions Controller/Adminhtml/Indexer/MassReindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

namespace Mageplaza\BackendReindex\Controller\Adminhtml\Indexer;

use Exception;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Indexer\IndexerInterface;
use Mageplaza\BackendReindex\Controller\Adminhtml\Indexer;

/**
Expand All @@ -42,15 +45,15 @@ public function execute()
} else {
try {
foreach ($indexerIds as $indexerId) {
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
/** @var IndexerInterface $indexer */
$indexer = $this->indexerRegistry->get($indexerId);
$indexer->reindexAll();
}
$this->messageManager->addSuccessMessage(__('Total of %1 index(es) have reindexed data.', count($indexerIds)));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addExceptionMessage($e, __("Cannot initialize the indexer process."));
} catch (Exception $e) {
$this->messageManager->addExceptionMessage($e, __('Cannot initialize the indexer process.'));
}
}
$this->_redirect('*/*/list');
Expand Down
8 changes: 5 additions & 3 deletions Controller/Adminhtml/Indexer/Reindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace Mageplaza\BackendReindex\Controller\Adminhtml\Indexer;

use Exception;
use Magento\Framework\Exception\LocalizedException;
use Mageplaza\BackendReindex\Controller\Adminhtml\Indexer;

/**
Expand All @@ -43,10 +45,10 @@ public function execute()
$indexer->reindexAll();

$this->messageManager->addSuccessMessage(__('%1 index was rebuilt.', $indexer->getTitle()));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addExceptionMessage($e, __("There was a problem with reindexing process."));
} catch (Exception $e) {
$this->messageManager->addExceptionMessage($e, __('There was a problem with reindexing process.'));
}
} else {
$this->messageManager->addErrorMessage(__('Cannot initialize the indexer process.'));
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "mageplaza/module-backend-reindex",
"description": "Magento 2 Backend Reindex Extension",
"require": {
"mageplaza/module-core": "^1.4.0"
"mageplaza/module-core": "^1.4.3"
},
"type": "magento2-module",
"version": "1.0.0",
"version": "1.0.1",
"license": "proprietary",
"authors": [
{
Expand Down

0 comments on commit 90a9ab6

Please sign in to comment.