Extend magento core controller (Checkout / OnepageController)

I'm having problems redefining the main controller. I want to add a new function, but it only works if I do it in the main file (code / core / checkout / controllers / onepagecontroller.php).

I went for some message, but it does not work. Some of them:

(I can not add more links, sorry)

I do not know what is happening ... maybe you can help me;).

I am using magento 1.5 and I have these 3 files:


local -> Arias -> CoreExtended -> etc -> config.xml

<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Arias_CoreExtended> <version>0.1.0</version> </Arias_CoreExtended> </modules> <frontend> <routers> <checkout> <args> <modules> <Arias_CoreExtended before="Mage_Checkout">Arias_CoreExtended_Checkout</Arias_CoreExtended> </modules> </args> </checkout> </routers> </frontend> </config> 

app → etc → modules → Arias_CoreExtended.xml

 <?xml version="1.0"?> <config> <modules> <Arias_CoreExtended> <active>true</active> <codepool>local</codepool> </Arias_CoreExtended> </modules> </config> 

local → Arias → CoreExtended → controllers → Checkout → OnepageController.php

 <?php require_once 'Mage/Checkout/controllers/OnepageController.php'; class Arias_CoreExtended_Checkout_OnepageController extends Mage_Checkout_OnepageController { public function collectAction() { echo 'WTF?'; } public function indexAction() { echo "This controller has been overridden."; } } 

Thanks in advance for your time.

+3
source share
3 answers

First, I would reflect the same directory structure of the controller that you are rewriting, so in this case change: local/Arias/CoreExtended/controllers/Checkout/OnepageController.php to local/Arias/CoreExtended/controllers/OnepageController.php

You should enter the namespace of the namespace / module in lowercase, and you need to remove _Checkout , since it overwrites the controllers in general and will look for everything that exists in the module to use them instead if not returning to the standard. The correct code is:

 <arias_coreextended before="Mage_Checkout">Arias_CoreExtended</arias_coreextended> 

I used this fine tuning with success to overwrite the Onepage controller!

+1
source

I would try the lower shell of your namespace / modulename like this:

<arias_coreextended before="Mage_Checkout">Arias_CoreExtended_Checkout</arias_coreextended>

0
source

Your approach is basically correct @satumo. The only thing you have to change is the line

 <Arias_CoreExtended before="Mage_Checkout">Arias_CoreExtended</Arias_CoreExtended> 

So your complete configuration should look like this:

 <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Arias_CoreExtended> <version>0.1.0</version> </Arias_CoreExtended> </modules> <frontend> <routers> <checkout> <args> <modules> <Arias_CoreExtended before="Mage_Checkout">Arias_CoreExtended</Arias_CoreExtended> </modules> </args> </checkout> </routers> </frontend> </config> 
0
source

Source: https://habr.com/ru/post/1435935/


All Articles