first of all we need to find an existing controller and we can insert this zipAction function on that controller
we can call this function as their front name of xml file and an index after that we can call this as zip

<a href="” class=”blueButton”>Download All Images

here mangeteam as their front name in xml
index is same
zip is zip action

getRequest()->getParams()[‘id’];
$_product = Mage::getModel(‘catalog/product’)->load($pid);
$file_arr=array();
foreach ($_product->getMediaGalleryImages() as $image) :
array_push($file_arr, (string) Mage::helper(‘catalog/image’)->init($_product, ‘image’, $image->getFile()));
endforeach;
$zipname=$_product->getName().’-product-images.zip’;
$zip = new ZipArchive;
$res = $zip->open($zipname, ZipArchive::CREATE);
if ($res === TRUE) {
foreach ($file_arr as $file) {
$download_file = file_get_contents($file);
$zip->addFromString(basename($file), $download_file);
}
$zip->close();
header(‘Content-Type: application/zip’);
header(‘Content-Length: ‘ . filesize($zipname));
header(‘Content-Disposition: attachment; filename=”‘.$zipname.'”‘);
readfile($zipname);
unlink($zipname);
}
}

?>

Advertisements