-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46d6261
Showing
8 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 MagePal, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace MagePal\Reindex\Controller\Adminhtml; | ||
|
||
abstract class Indexer extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* Check ACL permissions | ||
* | ||
* @return bool | ||
*/ | ||
protected function _isAllowed() | ||
{ | ||
switch ($this->_request->getActionName()) { | ||
case 'reindexOnTheFly': | ||
return $this->_authorization->isAllowed('Magento_Indexer::changeMode'); | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 MagePal, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace MagePal\Reindex\Controller\Adminhtml\Indexer; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
|
||
class ReindexOnTheFly extends \MagePal\Reindex\Controller\Adminhtml\Indexer | ||
{ | ||
|
||
/** @var \Magento\Framework\Indexer\IndexerInterface */ | ||
protected $indexerFactory; | ||
|
||
/** | ||
* Index constructor. | ||
* @param Context $context | ||
* @param \Magento\Indexer\Model\IndexerFactory $indexerFactory | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
\Magento\Indexer\Model\IndexerFactory $indexerFactory | ||
) { | ||
$this->indexerFactory = $indexerFactory; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function execute() | ||
{ | ||
$indexerIds = $this->getRequest()->getParam('indexer_ids'); | ||
if (!is_array($indexerIds)) { | ||
$this->messageManager->addError(__('Please select indexers.')); | ||
} else { | ||
try { | ||
|
||
foreach ($indexerIds as $indexerId) { | ||
$indexer = $this->indexerFactory->create(); | ||
$indexer->load($indexerId)->reindexAll(); | ||
|
||
} | ||
|
||
$this->messageManager->addSuccess(__('Reindex %1 indexer(s).', count($indexerIds)) | ||
); | ||
} catch (\Magento\Framework\Exception\LocalizedException $e) { | ||
$this->messageManager->addError($e->getMessage()); | ||
} catch (\Exception $e) { | ||
$this->messageManager->addException( | ||
$e, | ||
__("We couldn't reindex because of an error.") | ||
); | ||
} | ||
} | ||
|
||
$this->_redirect('*/*/list'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Reindex Magento 2 from Admin | ||
|
||
|
||
Reindex your Magento 2 store quickly and easily from backend/admin. Ideal for project managers or QA department during site development. | ||
|
||
#### 1 - Installation | ||
##### Manually | ||
* Download the extension | ||
* Unzip the file | ||
* Create a folder {Magento 2 root}/app/code/MagePal/Reindex | ||
* Copy the content from the unzip folder | ||
|
||
##### Using Composer | ||
|
||
``` | ||
composer require magepal/magento2-reindex | ||
``` | ||
|
||
#### 2 - Enable Reindex (from {Magento root} folder) | ||
* php -f bin/magento module:enable --clear-static-content MagePal_Reindex | ||
* php -f bin/magento setup:upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "magepal/magento2-reindex", | ||
"description": "Reindex Magento 2 from Admin", | ||
"keywords": [ | ||
"magento 2", | ||
"magento2", | ||
"reindex", | ||
"backend reindex", | ||
"admin reindex" | ||
], | ||
"require": { | ||
"php": "~5.5.0|~5.6.0|~7.0.0", | ||
|
||
"magento/magento-composer-installer": "*" | ||
}, | ||
"suggest": { | ||
|
||
}, | ||
"type": "magento2-module", | ||
"version": "1.0.0", | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"MagePal\\Reindex\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2017 MagePal. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> | ||
<router id="admin"> | ||
<route id="indexer"> | ||
<module name="MagePal_Reindex" after="Magento_Indexer" /> | ||
</route> | ||
</router> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2017 MagePal. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="MagePal_Reindex" setup_version="1.0.0"> | ||
<module name="Magento_Indexer"/> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 MagePal, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'MagePal_Reindex', | ||
__DIR__ | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2017 MagePal. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceBlock name="adminhtml.indexer.grid.grid.massaction"> | ||
<arguments> | ||
<argument name="options" xsi:type="array"> | ||
<item name="change_mode_admin_reindex" xsi:type="array"> | ||
<item name="label" xsi:type="string" translate="true">Reindex</item> | ||
<item name="url" xsi:type="string">*/indexer/reindexOnTheFly</item> | ||
</item> | ||
</argument> | ||
</arguments> | ||
</referenceBlock> | ||
</body> | ||
</page> |