-
- 24,544 Posts
Can you post a few lines of the CSV file?
discuss.answer
-
- 24,544 Posts
I assume the second number is the Resource ID. Give this a try:
$path = 'full/path/to/csv/file';
$fp = fopen($path, 'r');
if (!$fp) {
return "Could not open File " . $path . ' for reading';
}
$i = 0;
while (($line = fgets($fp)) !== false) {
/* Skip first line */
if ($i == 0) {
continue;
}
$i++;
$parts = explode(',', $line);
$docId = (int) $parts[1];
$doc = $modx->getObject('modResource', $docId);
if ($doc) {
$doc->set('deleted', true);
$doc->save();
}
}
fclose($fp);
return 'Marked ' . $i . ' resources for deletion.';
-
- 932 Posts
Do you have allow url fopen enabled in your php settings?
-
- 24,544 Posts
Remember that the code expects a physical path, not a URL. That way it won't need URL fopen.
You might try changing the CSV file's permissions to 644.
-
- 24,544 Posts
I'm glad we finally got it sorted.