Magento 1.7 - How to Extend a Kernel Controller

I am trying to extend the OnepageController with this setting:

application / etc / modules / Custom_Checkout.xml

<config> <modules> <Custom_Checkout> <active>true</active> <codePool>local</codePool> </Custom_Checkout> </modules> </config> 

Application / local / user / checkout / etc /config.xml

 <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Custom_Checkout> <version>0.0.1</version> </Custom_Checkout> </modules> <frontend> <routers> <checkout> <args> <modules> <custom_checkout before="Mage_Checkout">Custom_Checkout</custom_checkout> </modules> </args> </checkout> </routers> </frontend> </config> 

Application / Local / Custom / Order / Controllers / OnepageController.php

 require_once("Mage/Checkout/controllers/OnepageController.php"); class Custom_Checkout_OnepageController extends Mage_Checkout_OnepageController { public function indexAction() { echo "Index overidden"; } } 

I saw: Extend the main magento controller (Checkout / OnepageController)

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller

Plus something else that I can't post, but none of the above methods work. It just does not overwrite the controller.

Any ideas on why this is not texting?

+4
source share
2 answers

Unfortunately, there are many things that may be wrong here, and there is not enough information in your message to track them. Instead of an answer, here is a debugging tip. Take a look at the _validateControllerClassName function.

 protected function _validateControllerClassName($realModule, $controller) { $controllerFileName = $this->getControllerFileName($realModule, $controller); if (!$this->validateControllerFileName($controllerFileName)) { return false; } $controllerClassName = $this->getControllerClassName($realModule, $controller); if (!$controllerClassName) { return false; } // include controller file if needed if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) { return false; } return $controllerClassName; } 

Each return false is a state in which Magento may decide not to use your controller class for the request. Try adding some logging or var_dump input to $controllerFileName , $controllerClassName , both inside and outside the if statements. This is usually enough to indicate a small error in the name of the path to the file or class (case, missing character, etc.) for your module.

If you do not see any information related to Custom_Checkout , it means that Magento cannot see your module, and you should start debugging this.

+1
source

I think the solution should have the right case. Instead:

 <custom_checkout before="Mage_Checkout">Custom_Checkout</custom_checkout> 

This should be written:

 <custom_checkout before="Mage_Checkout">Custom_Checkout</custom_checkout> 
0
source

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


All Articles