1

We want to include some products which are actually held in an external site - however, they're not files, just pages within the external site. The external site manages authentication, access etc. and we just want to use Magento to sell a product which consists of a link to the remote site.

Downloadable products seemed to be the best option, but these are tailored towards downloadable files and so try to download a file from the supplied link.

Any suggestions on how we can do this?

4

Downloadable products are made for this. You can choose between an uploaded file or an URL for each downloadable item of the product:

Screenshot

Update: I was wrong

Magento proxies a download to the given URL instead of redirecting the customer, so some customization is necessary. I would still go with the downloadable product and add a new download type besides "File" and "URL", let's call it "Redirect"

  1. Define new link type

    Edit the form HTML in app/design/adminhtml/default/default/template/downloadable/product/edit/downloadable/links.phtml (copy the file to a custom admin theme and modify it). Create a new option for the downloadable[link][{{id}}][type] input called "redirect" (below "file" and "url"). There might be a more elegant way to change the template without this override, using JavaScript instead.

  2. Handle new link type

    Create a new controller for the "downloadable" route, using before="Mage_Downloadable" to override Mage_Downloadable_DownloadController::linkAction(). I would extend the original controller and just override the _processDownload($resource, $resourceType) method with something like this:

    protected function _processDownload($resource, $resourceType)
    {
        if ($resourceType === 'redirect') {
            //TODO: redirect to $resource
            return;
        } else {
            return parent::_processDownload($resource, $resourceType);
    }
    
  • My understanding is that if I supply a link there, it's a link to a file held on an external site. I've tried setting up the link to the website using that and after making a test purchase and going to downloadable products, I get an error saying 'An error occurred while getting the requested content. Please contact the store owner.'An error occurred while getting the requested content. Please contact the store owner. – SimonH Jun 29 '15 at 12:02
  • I double checked and you are right, Magento proxies a download to the given URL instead of redirecting the customer. You will need to add a custom download type... – Fabian Schmengler Jun 29 '15 at 13:56
  • Please see updated answer. – Fabian Schmengler Jun 29 '15 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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