I'm trying to create a function to download all product images from a site as a zip file. I need to get the all the images paths as an array to pass to a zip file creator function. I'm halfway there. I can get get all the images needed as a DataObject but now I need to pass just the Filename column as an array. This is what I have so far:
public function DownloadAllImages(){
//$records = DataObject::get("ToyImage", "Type= 'Normal'");
$records = DB::query("SELECT * FROM ToyImage WHERE Type ='Normal'");
$returnImages = new DataObjectSet();
$filePaths = array();
if ($records) {
//return $records;
foreach($records as $record){
$imageID = $record['AttachmentID'];
$returnImages->push(new ArrayData(array(
'Name' => DataObject::get_by_id('File', $imageID)
)));
}
return $returnImages;
} else {
return false;
}
}
Thanks in advance