Magento – Download LINK for product all images magento

catalogmagento-1.9product-images

I am new to Magento. I have a Magento 1.9 site where I am required to provide a Downloadable link for all images of a particular product that should automatically get downloaded on button click.

Is there any free extension for this purpose. Please help me

Best Answer

Actually their is no need of any third party extension for this task you can implement the same by your own.

This is with assumption that you want the download button or link on product detail page.

Place the following code on app\design\frontend\<YOUR_PACKAGE>\<YOUR_THEME>\template\catalog\product\view.phtml

<?php
                $file_arr=array();
                foreach ($_product->getMediaGalleryImages() as $image) :
                    array_push($file_arr, (string) Mage::helper('catalog/image')->init($_product, 'image', $image->getFile()));
                endforeach;
                create_zip($file_arr);

                function create_zip($files = array())
                {
                    $zip = new ZipArchive;
                    $res = $zip->open('ProductImages.zip', ZipArchive::CREATE);
                    if ($res === TRUE) {
                        foreach ($files as $file) {
                            $download_file = file_get_contents($file);
                            $zip->addFromString(basename($file), $download_file);
                        }
                        $zip->close();
                    }
                }
                $url =  Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
                ?>
                <a href="<?php echo $url.'ProductImages.zip'?>">Download</a>

I have implement the code with download link by some modification you can achieve the same with button.

Hope this will help you.

Related Topic