indexerRegistry = $indexerRegistry; } /** * @inheritDoc */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { if ($this->isNeedToDoReindex($setup)) { $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); $indexer->reindexAll(); } } /** * Check is re-index needed * * @param ModuleDataSetupInterface $setup * @return bool */ private function isNeedToDoReindex(ModuleDataSetupInterface $setup) : bool { return !$setup->tableExists('customer_grid_flat') || $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID) ->getState() ->getStatus() == StateInterface::STATUS_INVALID; } }