Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassChangelog.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
10 
11 class MassChangelog extends \Magento\Indexer\Controller\Adminhtml\Indexer implements HttpPostActionInterface
12 {
18  public function execute()
19  {
20  $indexerIds = $this->getRequest()->getParam('indexer_ids');
21  if (!is_array($indexerIds)) {
22  $this->messageManager->addError(__('Please select indexers.'));
23  } else {
24  try {
25  foreach ($indexerIds as $indexerId) {
27  $model = $this->_objectManager->get(
28  \Magento\Framework\Indexer\IndexerRegistry::class
29  )->get($indexerId);
30  $model->setScheduled(true);
31  }
32  $this->messageManager->addSuccess(
33  __('%1 indexer(s) are in "Update by Schedule" mode.', count($indexerIds))
34  );
35  } catch (\Magento\Framework\Exception\LocalizedException $e) {
36  $this->messageManager->addError($e->getMessage());
37  } catch (\Exception $e) {
38  $this->messageManager->addException(
39  $e,
40  __("We couldn't change indexer(s)' mode because of an error.")
41  );
42  }
43  }
44  $this->_redirect('*/*/list');
45  }
46 }
__()
Definition: __.php:13