views:

137

answers:

1

I'm trying to override the linkAction method so that I can serve up downloadables in S3, etc.

+2  A: 

This got considerably easier in the Magento 1.3 branch. All you need to do is add is

<frontend>
 <routers>
    <downloadable>
   <args>
     <modules>
    <modulename before="Mage_Downloadable">Yourpackagename_Yourmodulename</modulename>
     </modules>
   </args>
    </downloadable>
 </routers>
</frontend>

The <downloadable> tag should match the <routers> tag in the module you're trying to override. Mage_Downloadable is the classname prefix of the same. Yourpackagename_Yourmodulename is the classname prefix of your module.

With this in place, Magento will check your module's controllers first for a match.

app/code/local/Packagename/Modulename/controllers/DownloadController.php

If no matching action is found, it'll fall back to the original. Be sure to checkout my Magento Controller Dispatch Logging article for help debugging routing issues.

What's awesome about this approach (as opposed to the rewrite approach) is you

  1. Don't need to manually require the old controller file in your controller

  2. You don't need to provide new layout rules. Magento seems to magically keep the layout handles as they were

Alan Storm