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

Overriding controller:  path doesn’t begin with Mage_
 
zburnham
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-07
Westborough, MA
 

So I’m adding a module to /app/code/local/Company/MyClass/Checkout/ in order to be able to override a controller in /app/code/core/Mage/Checkout/.

Here’s what I’ve done so far:

Added the following to /app/etc/local.xml:

<modules>
    <
Company_MyClass>
        <
active>true</active>
        <
codePool>local</codePool>
    </
Company_MyClass>
</
modules>

Created the folder /app/code/local/Company/MyClass/Checkout/controllers and put a file called CartController.php in it.
This file contains:

<?php

require_once('Mage/Checkout/controllers/CartController.php');

class 
Company_MyClass_Checkout_CartController extends Mage_Checkout_CartController 
{
    
public function indexAction()
    
{

    }
}

Created the folder /app/code/local/Company/MyClass/Checkout/etc and created a file called config.xml in it.  This file contains:

<?xml version="1.0"?>
<config>
    <
modules>
        <
Company_MyClass>
            <
version>0.1.0</version>
        </
Company_MyClass>
    </
modules>
    
    <global>      
        <
resources>
            <
myclass_setup>
                <
setup>
                    <
module>Company_MyClass</module>
                </
setup>
                <
connection>
                    <use>
core_setup</use>
                </
connection>
            </
myclass_setup>
        </
resources>
    </global>
    
    <
frontend>
        <
routers>
            <
myclass>
                <use>
standard</use>
                <
args>
                    <
module>Company_MyClass</module>
                    <
frontName>myclass</frontname>
                </
args>
            </
myclass>
        </
routers>
    </
frontend>   
</
config>

Edited /app/design/frontend/default/default/layout/checkout.xml to contain the following:

<myclass_checkout_cart_index>
    <
update handle="checkout_cart_index"/>
</
myclass_checkout_cart_index>

And lastly, added the following entry to core_url_rewrite in my database:

INSERT INTO `core_url_rewriteVALUES (6930'myclass/1''checkout/cart''myclass/checkout/cart'''0NULL);

So it doesn’t crash smile but it gives me a 404 when I go to /index.php/checkout/cart/ .  I’m sure there’s something little I’ve missed here but I’ve been trying to figure it out all day.  Any suggestions are welcome.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Hedrén
Member
 
Total Posts:  67
Joined:  2007-08-31
Sweden
 

I’m not really sure about this, but I think you should move your controller-class to Company/Myclass/controllers/Checkout/Cart.php and edit the rewrite like this:

INSERT INTO `core_url_rewriteVALUES (6930'myclass/1''checkout/cart''myclass/checkout_cart'''0NULL);

Maybe it works just by using the rewrite above…

 
Magento Community Magento Community
Magento Community
Magento Community
 
zburnham
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-07
Westborough, MA
 

Sadly, that didn’t seem to do the trick.  I also tried ‘checkout/cart’ getting mapped to ‘myclass/cart’, but that didn’t work either. 

Have the Varien folks been reading this forum lately?  I remember getting replies the same day previously.  I know that they’re probably busy getting the release together, but maybe someone could throw us a bone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zburnham
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-07
Westborough, MA
 

More information can be found in this thread: http://www.magentocommerce.com/boards/viewthread/3332/

It covers a lot of the same ground.

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