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

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.