Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IndexerResetStateCommand.php
Go to the documentation of this file.
1 <?php
7 
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
13 
18 {
22  protected function configure()
23  {
24  $this->setName('indexer:reset')
25  ->setDescription('Resets indexer status to invalid')
26  ->setDefinition($this->getInputList());
27 
28  parent::configure();
29  }
30 
34  protected function execute(InputInterface $input, OutputInterface $output)
35  {
36  $indexers = $this->getIndexers($input);
37  foreach ($indexers as $indexer) {
38  try {
39  $indexer->getState()
40  ->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID)
41  ->save();
42  $output->writeln($indexer->getTitle() . ' indexer has been invalidated.');
43  } catch (LocalizedException $e) {
44  $output->writeln($e->getMessage());
45  } catch (\Exception $e) {
46  $output->writeln($indexer->getTitle() . ' indexer process unknown error:');
47  $output->writeln($e->getMessage());
48  }
49  }
50  }
51 }
execute(InputInterface $input, OutputInterface $output)