📜  在发布 api magento 2 后重新索引 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:09.675000             🧑  作者: Mango

代码示例1
$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();
    }