OnepageController does not overload / overwrite my user controller

I am trying to reboot / rewrite the Onepagecontroller core using my custom controller in the local pool, but it does not work. I am using Magento 1.5.1

Here is my file structure and code:

Controller File: \ Application \ Code \ Local \ ODC \ Mycheckout \ Controllers \ OnepageController.php

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

config.xml file: \ Application \ Code \ Local \ ODC \ Mycheckout \ etc. \ config.xml

  <?xml version="1.0"?> <config> <modules> <Odc_Mycheckout> <version>0.0.1</version> </Odc_Mycheckout> </modules> <global> <controllers> <Mage_Checkout> <rewrite> <onepage>Odc_Mycheckout_Onepage</onepage> </rewrite> </Mage_Checkout> </controllers> </global> <frontend> <routers> <mycheckout> <args> <modules> <Odc_Mycheckout before="Mage_Checkout">Odc_Mycheckout</Odc_Mycheckout> </modules> </args> </mycheckout> </routers> </frontend> </config> 

File Odc_Mycheckout.xml: \ Application \ etc. \ module \ Odc_Mycheckout.xml

  <?xml version="1.0"?> <config> <modules> <Odc_Mycheckout> <active>true</active> <codepool>local</codepool> </Odc_Mycheckout> </modules> </config> 
+4
source share
2 answers

CamelCase strikes again.

File Odc_Mycheckout.xml: \ Application \ etc. \ module \ Odc_Mycheckout.xml

  <?xml version="1.0"?> <config> <modules> <Odc_Mycheckout> <active>true</active> <codePool>local</codePool> <!-- Capital P in pool --> 

In addition, in your module configuration file:

  <frontend> <routers> <checkout> <!-- must match the router config you are trying to override --> <args> <modules> <Odc_Mycheckout before="Mage_Checkout">Odc_Mycheckout</Odc_Mycheckout> </modules> </args> </checkout> </routers> </frontend> 

EDIT:

For troubleshooting when rewritable controllers do not work, it can help get back to basics. One approach is to use the same methods as Mage_Core_Controller_Varien_Router_Standard . In script test.php:

 <?php ini_set('display_errors',1); include 'app/Mage.php'; Mage::setIsDeveloperMode(true); Mage::app(); $module = 'Odc_Mycheckout'; $controller = 'Onepage'; $router = new Mage_Core_Controller_Varien_Router_Standard; $filename = $router->getControllerFileName($module,$controller); $classname = $router->getControllerClassName($module,$controller); include $filename; $controller = Mage::getControllerInstance( $classname, Mage::app()->getRequest(), Mage::app()->getResponse() ); var_dump($controller); //should be a class 
+6
source

The following tags are not needed.

  <global> <controllers> <Mage_Checkout> <rewrite> <onepage>Odc_Mycheckout_Onepage</onepage> </rewrite> </Mage_Checkout> </controllers> </global> 
0
source

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


All Articles