This question has been answered by BobRay. See the first response.
$c = $modx->newQuery('modResource');
$c->where('tag criteria'); // This will depend on how they're tagged
// I would add 'deleted' -> '0' to the where so you can run it repeatedly in case it times out.
$docs = $modx->getCollection('modResource', $c);
foreach ($docs as $doc) {
$doc->set('deleted', '1');
$doc->save();
}I don't recommend removing them from the DB. That will leave behind all kinds of intersects connecting them to Templates and TVs.
The Batcher extra will let you select them and will remove them properly.
Depending on what the CSV file looks like, it should be possible to create a utility snippet to either load them and call $doc->remove(), or (safer) mark them as deleted and then click on the trashcan icon in the Resources tree.
If you can create a query to select them by their tags, it would be faster and easier to get them with getCollection() and loop through them to mark them as deleted. You could use remove(), but if the script times out, you may end up with partially removed resources. I would do it like this:
$c = $modx->newQuery('modResource'); $c->where('tag criteria'); // This will depend on how they're tagged // I would add 'deleted' -> '0' to the where so you can run it repeatedly in case it times out. $docs = $modx->getCollection('modResource', $c); foreach ($docs as $doc) { $doc->set('deleted', '1'); $doc->save(); }
If that times out, you may have to empty the trash and run it again. It might be wise to clear the cache between runs as well.
I don't recommend removing them from the DB. That will leave behind all kinds of intersects connecting them to Templates and TVs.
The Batcher extra will let you select them and will remove them properly.
Depending on what the CSV file looks like, it should be possible to create a utility snippet to either load them and call $doc->remove(), or (safer) mark them as deleted and then click on the trashcan icon in the Resources tree.
If you can create a query to select them by their tags, it would be faster and easier to get them with getCollection() and loop through them to mark them as deleted. You could use remove(), but if the script times out, you may end up with partially removed resources. I would do it like this:
$c = $modx->newQuery('modResource'); $c->where('tag criteria'); // This will depend on how they're tagged // I would add 'deleted' -> '0' to the where so you can run it repeatedly in case it times out. $docs = $modx->getCollection('modResource', $c); foreach ($docs as $doc) { $doc->set('deleted', '1'); $doc->save(); }
If that times out, you may have to empty the trash and run it again. It might be wise to clear the cache between runs as well.
$c->where('tag criteria');
$c->where('mytagname');
Do you have any other information in your CSV that could help? Batcher has a bunch of fields in the advanced search that may be helpful?
How did you create the CSV file?