How to massively update resources?

I added the resources via to the database in the site_content table. These resources are displayed in the modx resource tree. But they didn’t have an alias. It appears automatically only after I click the “Save” button
Is it possible to automate this process somehow?
I saw some php code for Console, but it didn’t help

Maybe this snippet code works:

$resources = $modx->getIterator('modResource'); //query all resources
foreach ($resources as $resource) {
    $alias = $resource->get('alias'); //current alias
    if (empty($alias)){ //current alias is empty
        $alias = $resource->cleanAlias($resource->get('pagetitle')); //create new alias from the pagetitle
        $resource->set('alias', $alias);
$modx->cacheManager->refresh(); //clear the cache
1 Like