0

can you help me? i train make rewrite controller on magento 1.9.2.4 and i'm using php 7, my code like this Lesson/Test/controllers/CartController.php

<?php require_once "Mage/Checkout/controllers/CartController.php"; class Lesson_Test_CartController extends Mage_Checkout_CartController { # Rewrite of indexAction public function indexAction() { die('your method has been rewrited !!'); } } 

Lesson/Test/etc/config.xml

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

etc/modules/Lesson_All.xml

<?xml version="1.0"?> <config> <modules> <Lesson_Test> <active>true</active> <codePool>local</codePool> </Lesson_Test> </modules> </config> 

but it not work, 404 not found, i acces http://127.0.0.1/magento/magento-tutorial/index.php/lesson thank you magento :) i'm learn from this

2
  • 2
    What if you access 127.0.0.1/magento/magento-tutorial/index.php/checkout/cart ? As it is an overriden controller you should access the native controller route and your overriden controller class would be used instead Commented Jun 6, 2016 at 8:56
  • thanks @RaphaelatDigitalPianism its solved my problem, i was wrong for my access Commented Jun 6, 2016 at 21:39

1 Answer 1

2

I'm not sure what you are trying to achieve here.
But rewriting a controller, does not mean that you can change the url key for that controller.
Your custom code should be called when your url is checkout/cart/index or simply checkout/cart.
There is no route defined for lesson in your config.xml.
If you want that to work you need to add this inside the routers tag:

 <lesson> <use>standard</use> <args> <module>Lesson_Test</module> <frontName>lesson</frontName> </args> </lesson> 

and your controller will also respond at the url lesson/cart.
If you are trying to change the url key for checkout from checkout to lesson you need to add this inside the routes node in config.xml

 <checkout> <args> <frontName>lesson</frontName> </args> </checkout> 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.