I have attempted my first rewrite module since i needed to make some edits to a core controller. For whatever reason it is not working as the edits are not taking effect. Here are my files:
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
{
/**
* Save payment ajax action
*
* Sets either redirect or a JSON response
*/
public function indexAction(){
echo 'Hello World';
}
}
I am actually only editing a small section in this code, I tried to highlight it, I added an if operation. Not sure if there is a way to only edit this portion or if I need to replace the entire function?
app/code/local/PaypalExtended/Checkout/etc/config.xml and its code is
<?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>
I have tried numerous edits including moving my controller out of the checkout folder into the controllers folder. I have made edits to my config.xml file to reference different locations and files. I have followed most of the guides/answers on here and none have worked so far.
Can anyone help me get this working? Is there any suggestions to clean my code up, make them shorter? Thanks!
—EDITS MOVED FOLDERS AND CHANGED NAMES/CODE TO MAKE IT SIMPLER TO GET WORKING
—
———————————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
Config.xml is code
controller code is
How to override, a controller see my blog http://www.amitbera.com/how-to-override-a-controller-in-magento/