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

customize backend controller
 
ralphie
Member
 
Total Posts:  59
Joined:  2007-12-20
London
 

hi all

i am getting mad.. i successfully customized a front end controller.. and now i should do the same in the backend.. and somehow i just dont get it to work. can anybody see my error? thanks a lot. i assume the error is somewhere in the config.xml.. it was once working, but then it was called not via the /admin/ url which it obiously needs to be called.. i just dont see it..

my files look as follows:

app/etc/modules/MyNameSpace_All.xml

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

app/code/local/MyNameSpace/MyModule/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNameSpace_MyModule>
            <
version>0.1.0</version>
        </
MyNameSpace_MyModule>
    </
modules>
    <global>
        <
rewrite>
            <
mynamespace_mymodule_sales_shipment>
                <
from><![CDATA[#^/admin/sales_shipment/pdfshipments/$#]]></from>
                
<to>/admin/mymodule/sales_shipment/pdfshipments</to>
            </
mynamespace_mymodule_sales_shipment>
        </
rewrite>
    </global>
    <
adminhtml>
        <
routers>
            <
mynamespace_mymodule>
                <use>
admin</use>
                <
args>
                    <
module>MyNameSpace_MyModule</module>
                    <
frontName>mymodule</frontName>
                </
args>
            </
mynamespace_mymodule>
        </
routers>
    </
adminhtml>
</
config>

and then the actual code where i try to overload the pdfshipments function.. in app/code/local/MyNameSpace/MyModule/controllers/Adminhtml/Sales/ShipmentController.php

class MyNameSpace_MyModule_Adminhtml_Sales_ShipmentController extends Mage_Adminhtml_Sales_ShipmentController
{

    
public function pdfshipmentsAction(){
        
//...
    

}
 
Magento Community Magento Community
Magento Community
Magento Community
 
ralphie
Member
 
Total Posts:  59
Joined:  2007-12-20
London
 

hmm.. i figured out a way how i can successfully overlaod a backend controller.. my config.xml looks like that:

<?xml version="1.0"?>
<?xml version
="1.0"?>
<config>
    <
modules>
        <
mynamespace_mymodule>
            <
version>0.1.0</version>
        </
mynamespace_mymodule>
    </
modules>
    <global>
        <
rewrite>
            <
mynamespace_mymodule_adminhtml_sales_shipment>
                <
from><![CDATA[#^/admin/sales_shipment/pdfshipments/$#]]></from>
                
<to>/MyModule/sales_shipment/pdfshipments</to>
            </
mynamespace_mymodule_adminhtml_sales_shipment>
        </
rewrite>
    </global>
    <
admin>
        <
routers>
            <
mynamespace_mymodule>
                <use>
admin</use>
                <
args>
                    <
module>MyNameSpace_MyModule</module>
                    <
frontName>mymodule</frontName>
                </
args>
            </
mynamespace_mymodule>
        </
routers>
    </
admin>
</
config>

however i am really wondering whether this is the way to do it or not. am a bit confused with the rewrite path.. somehow miss admin in there.. would be great if anyone could give me a thumb up or down if this is the way to do it. also i am wondering if the admin bit in the path does determine if a resource is under the (admin) access control. but as i understand this rewrite is purely internal and therefore no security leak is opened up like that, right?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ralphie
Member
 
Total Posts:  59
Joined:  2007-12-20
London
 

oh, and maybe i am outing myself as dumb but it is not possible to do controller overriding without xml definition, right? -> like it is possible for blocks for instance.. just duplicate into the local path..

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