I'm trying to index some asset volumes that I'm creating in a migration. These are local volumes which may already contain files.
I'm hoping to avoid the step where I have to manually update the asset indices after creating volumes.
The following code does not seem to perform the index, am I missing a step? I've studied the controller used by Utilities but I can't see where I'm going wrong.
$volumeId = Craft::$app->volumes->getVolumeByHandle('myVolume')->id; $indexer = Craft::$app->getAssetIndexer(); $sessionId = $indexer->getIndexingSessionid(); $indexer->processIndexForVolume($sessionId,$volumeId);
Any help is much appreciated