Magento 1.9 – Edits to Core Controllers OnepageController.php Not Working

controllersmagento-1.9onepage-checkout

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!

Best Answer

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/

Related Topic