public function reindexProducts() { $products = $this->productRepository->findAll(); $this->searchIndexManager->eraseIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME); foreach ($products as $product) { $this->addProduct($product); } $index = $this->searchIndexManager->getIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME); $index->optimize(); }