📅  最后修改于: 2022-03-11 14:54:09.675000             🧑  作者: Mango
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("\Magento\Indexer\Model\Indexer\CollectionFactory");
$indexerFactory = $objectManager->get("\Magento\Indexer\Model\IndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id) {
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
}