1

I am starting a new question for this because I created a clean magento install and still can't get any overwrites to work for the controllers. My edits for models and blocks all work fine but I have not been able to get it to work for the controller.

Could this be an issue with Magento 1.9 specifically? Are there new requirements to configure? All the examples and tutorials are based on an older version.

Here is what i have so far:

app/code/local/Paypalextended/Checkout/controllers/OnepageController.php

<?php
# Controllers are not autoloaded so we will have to do it manually: 
require_once 'Mage/Checkout/controllers/OnepageController.php';
class Paypalextended_Checkout_OnepageController extends Mage_Checkout_OnepageController
{
  public function indexAction(){

echo 'Hello World';
}

}

app/code/local/Paypalextended/Checkout/etc/config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Paypalextended_Checkout>
        <version>0.1.0</version>
    </Paypalextended_Checkout>
</modules>
<!-- 
 If you want to overload an admin controller this tag should be <admin> instead,
or <adminhtml> if youre overloading such stuff (?)
-->
<frontend>
    <routers>
        <checkout>
            <args>
                <modules>
                <Paypalextended_Checkout before="Mage_Checkout">Paypalextended_Checkout</Paypalextended_Checkout>
                </modules>
            </args>
        </checkout>
    </routers>
</frontend>
</config>

app/etc/modules/Paypalextended_All.xml

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

As I mentioned this is on a brand new install so there should be nothing interfering. Still it doesnt work. Is there a setting needed somewhere to allow controller overwrites?

I have tried moving the folder location to:

app/code/local/Paypalextended/Checkout/controllers/Checkout/OnepageController.php

and changing all the references appropriately. I saw this in a couple different tutorials. I tried everything in the wiki including the rewrite method and still nothing. I have made dozens of config.xml edits, instead of require_once include_once, changing the require_once line to:

require_once Mage::getModuleDir('controllers', "Mage_Checkout").DS."OnepageController.php";

I am beginning to think the problem is something specific to magento 1.9, has anyone ran into this or has successfully done a controller overwrite in magento 1.9? All advice appreciated!!!!

---------------------------------ANSWER-------------------------------------- So the problem ended up being that I had a leading empty line in my config.xml file... After that was removed both methods listed below worked perfectly. BIG thanks to Amit for his assistance!

4
  • Your issue is definitely not related to the version of Magento.
    – mbalparda
    Jul 30, 2014 at 16:22
  • Do you see an issue? I created a clean install just to get this working, I followed every tutorial out there I could find and suggestions. Nothing has worked so far, any ideas? Jul 30, 2014 at 16:33
  • As a quick advise, do this: download a Magento Connect extension for Checkout and see how the override of the controller is made there. 80% of checkout extensions in Magento Connect will do that.
    – mbalparda
    Jul 30, 2014 at 17:54
  • Do you have a specific one in mind that you know overrides a checkout controller. I have also tried the above method with the cartcontroller and still no success. Jul 30, 2014 at 18:04

2 Answers 2

0

Hi i have try basic Magento redirect,It is working

I have modify config.xml now, it is working

<?xml version="1.0"?>
<config>
<modules>
    <PaypalExtended_OnepagePaypal>
        <version>0.1.0</version>
    </PaypalExtended_OnepagePaypal>
</modules>
<!--
<frontend>
    <routers>
        <checkout>
            <args>
             <modules>
               <PaypalExtended_OnepagePaypal before="Mage_Checkout">PaypalExtended_OnepagePaypal_Checkout</PaypalExtended_OnepagePaypal>
                </modules>
            </args>
        </checkout>
    </routers>
</frontend>
-->
<global>
        <!-- This rewrite rule could be added to the database instead -->
        <rewrite>
            <!-- This is an identifier for your rewrite that should be unique -->
            <!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
            <customonepageunique>
                <from><![CDATA[#^/checkout/onepage/#]]></from>
                <!--
                    - mymodule matches the router frontname below
                    -  matches the path to your controller

                    Considering the router below, "/customonepage/index/" will be
                    "translated" to "app/code/local/PaypalExtended/OnepagePaypal/controllers/Checkout/OnepageController.php" (?)
                -->
                <to>/customonepage/checkout_onepage/</to>
            </customonepageunique>
        </rewrite>
    </global>

    <frontend>
        <routers>
            <customonepage>
                <!-- should be set to "admin" when overloading admin stuff (?) -->
                <use>standard</use>
                <args>
                    <module>PaypalExtended_OnepagePaypal</module>
                    <!-- This is used when "catching" the rewrite above -->
                    <frontName>customonepage</frontName>
                </args>
            </customonepage>
        </routers>
    </frontend>
</config>

It is more efficient Process

Read more at:http://www.amitbera.com/how-to-override-a-controller-in-magento/

0

Just on a quick look your class should extend

Mage_Checkout_Controller_Action instead of Mage_Checkout_OnepageController

I would start there. Also do you get an error page or is it just the standard checkout page.

Also try removing The Checkout before OnepageController.php , so it reads

app/code/local/Paypalextended/Checkout/controllers/OnepageController.php

This was one of the more annoying extends I have done so I feel your pain.

EDIT: Now that I look at it you might need to change the filename of

Paypalextended_All.xml to Paypalextended_Checkout.xml.

I didn't notice this when i first looked at the code.

7
  • Hello, I will try the first part and see what I get. For the second part. I put Checkout in place of what used to be my module name some tutorials said to do that so I tried and just left it. I will let you know the other results in a couple minutes Jul 30, 2014 at 18:27
  • Just re-read the second part. I have already made that change but I also tried the other folder location. I just tried your first suggestion, still nothing unfortunately... Any other ideas? Jul 30, 2014 at 19:03
  • What is happening exactly? Is the checkout not showing up or is it just the standard one?
    – Egregory
    Jul 30, 2014 at 21:27
  • It is just the standard one, completely ignoring my edits basically. Jul 31, 2014 at 17:31
  • Can you see the module in the magento admin go to System >configuration > advanced >advanced and check to see if your module is there. If not than your module isn't being seen and you will have to check why.
    – Egregory
    Jul 31, 2014 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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