Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Overloading the Downloadable Controller
 
dpdexter
Jr. Member
 
Total Posts:  11
Joined:  2007-11-12
Los Angeles
 

We are trying to overload the downloadable controller to write our own naming convention for purchased downloads but we can’t seem to get magento to see our custom module.

We followed the checkout example and that worked fine; However, magento just won’t see our downloadable module.

From /app/code/local/B2NameSpace/Downloadable/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
B2NameSpace_Downloadable>
            <
version>0.1.0</version>
        </
B2NameSpace_Downloadable>
    </
modules>
    <global>
        <
rewrite>
            <
b2nameSpace_downloadable_download>
                <
from><![CDATA[#^/downloadable/download\//#]]></from>
                
<to>/downloadable/download/</to>
            </
b2nameSpace_downloadable_download>
        </
rewrite>
    </global>
</
config>

From: /app/etc/modules/B2NameSpace_All.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
B2NameSpace_Checkout>
            <
active>true</active>
            <
codePool>local</codePool>
        </
B2NameSpace_Checkout>

        <
B2NameSpace_Downloadable>
            <
active>true</active>
            <
codePool>local</codePool>
            <
depends>
                <
Mage_Catalog />
            </
depends>
        </
B2NameSpace_Downloadable>    
    </
modules>
</
config>

We just can’t seem to get Magento to overload our custom module. If we replace the core class with our rewrite it works perfectly.

Any help would be greatly appreciated!

Best, David

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michae1
Enthusiast
 
Total Posts:  826
Joined:  2007-08-31
 

Hi David,

Please try the following:

app/etc/modules/etc/B2NameSpace_All.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
B2NameSpace_Downloadable>
            <
active>true</active>
            <
codePool>local</codePool>
            <
depends>
                <
Mage_Catalog />
            </
depends>
        </
B2NameSpace_Downloadable>
    </
modules>
</
config>

app/code/local/B2NameSpace/Downloadable/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
B2NameSpace_Downloadable>
            <
version>0.1.0</version>
        </
B2NameSpace_Downloadable>
    </
modules>
    <global>
        <
rewrite>
            <
b2nameSpace_downloadable_download>
                <
from><![CDATA[#^/downloadable/download\/#]]></from>
                
<to>/b2downloadable/download/</to>
            </
b2nameSpace_downloadable_download>
        </
rewrite>
    </global>
    <
frontend>
        <
routers>
            <
b2downloadable>
                <use>
standard</use>
                <
args>
                    <
module>B2NameSpace_Downloadable</module>
                    <
frontName>b2downloadable</frontName>
                </
args>
            </
b2downloadable>
        </
routers>
    </
frontend>
</
config>

app/code/local/B2NameSpace/Downloadable/controllers/DownloadController.php

<?php

class B2NameSpace_Downloadable_DownloadController extends Mage_Core_Controller_Front_Action
{

    
/**
     * Download link action
     */
    
public function linkAction()
    
{
        
die('You are trying to download something');
    
}

}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top