I modified my list.php to get the download link button instead of "add to cart" button when I have a free download file. I know that in this way I can't get statistic of download but for now this is not a problem.

Here my code:

<?php if(!($_product->getIsVirtual() && $_product->getFinalPrice() == 0)): ?>
                        <p class="action"><button type="button" title="<?php echo $this->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>

                            <?php else:
                            $_myprodlinks = Mage::getModel('downloadable/link');
                            $_myLinksCollection = $_myprodlinks->getCollection()->addProductToFilter($_product->getId());
                            if (sizeof($_myLinksCollection)>0):
                            foreach ($_myLinksCollection as $_link):
                            $mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
                            $_linkpath = $mediaUrl."downloadable/files/links".$_link->getLinkFile();
                                <a href="<?php echo $_linkpath ?>" target="_blank" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('downloadable')->__('Start Download')) ?>"><button type="button" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('downloadable')->__('Start Download')) ?>" class="button btn-cart"><span><span><?php echo Mage::helper('core')->quoteEscape(Mage::helper('downloadable')->__('Start Download')) ?></span></span></button></a>
                        <?php endif;?>

This works fine! I have the button and the link has the right url like this


Through FTP I have verified the presence of the file, but this link return me a 404 page. I have read some similar topics and I tried to change the permission of folders and files, but nothing change. Any suggestion?


2 Answers 2


I know this does not solve your problem, but maybe it makes you rework the functionality:

Actually the correct behaviour when accessing files directly from /media/downloadable/ should be a Permission denied.


Anyone could just do a directory traversal in your /media or /media/downloadable directory and download all the files in there automatically.

If you don't care about this fact: go ahead.

If you do: Try to find another solution to download the files.

You can use the Sample section/function of the downloadable products which is intended to be used to preview the files. Just upload your file there.


Check the rules in:

  • ./.htaccess
  • ./meda/.htaccess
  • ./media/downloadable/.htaccess

Verify that ./get.php is callable

  • you're right, in media/downloadable/.htaccess there is Order deny,allow deny from all that cause the 404 error. If you don't care about directory traversal (see @Anna Völkl) just set allow form all
    – laura
    Commented Dec 10, 2015 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.