Skip to content

Instantly share code, notes, and snippets.

@CrazyBoy49z
Created April 1, 2020 13:48
Show Gist options
  • Save CrazyBoy49z/326b9ce1f61424368d26f16c3dbd3fa7 to your computer and use it in GitHub Desktop.
Save CrazyBoy49z/326b9ce1f61424368d26f16c3dbd3fa7 to your computer and use it in GitHub Desktop.
<?php
$stercseo = $modx->getService('stercseo', 'StercSEO', $modx->getOption('stercseo.core_path', null, $modx->getOption('core_path').'components/stercseo/').'model/stercseo/', array());
if (!($stercseo instanceof StercSEO)) {
return;
}
$resources = $modx->getCollection("modResource");
foreach ($resources as $k => $resource) {
$properties = $resource->getProperties('stercseo');
if (!empty($properties)) {
$newProperties = [
'index' => $properties['index'],
'follow' => $properties['follow'],
'sitemap' => $properties['sitemap'],
'priority' => $properties['priority'],
'changefreq' => $properties['changefreq']
];
} else {
$newProperties = [
'index' => $stercseo->getOption('stercseo.index', null, '1'),
'follow' => $stercseo->getOption('stercseo.follow', null, '1'),
'sitemap' => $stercseo->getOption('stercseo.sitemap', null, '1'),
'priority' => $stercseo->getOption('stercseo.priority', null, '0.5'),
'changefreq' => $stercseo->getOption('stercseo.changefreq', null, 'weekly')
);
}
$resource->setProperties($newProperties, 'stercseo');
$resource->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment