Ranjeet singh
Ranjeet singh

Reputation: 794

Extending magento core controller but not working

I am extending the magento core controller but it can't working. it cannot display any error. I have creating a module for it. the module is shown at the back-end in system/configuration/advanced . I have two files controller and etc. Controller/AccountController.php:

<?php
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
//we need to add this one since Magento wont recognize it automatically

class Inchoo_Coreextended_Frontend_Customer_AccountController extends Mage_Customer_AccountController
{//here, you extended the core controller with our
public function indexAction()
{
parent::indexAction();
//you can always use default functionality
}
public function myactionAction()
{
//my code
//you can write your own methods / actions
}
public function mymethod()
{
//my code
//you can write your own methods
}
public function loginAction()
{
    echo "har har mahadev";
//finally you can write your code that will rewrite the whole core method
//and you can call for your own methods, as you have full control over core controller
}
} 

and etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Inchoo_Coreextended>
            <version>0.2.0</version>
        </Inchoo_Coreextended>
    </modules>
    <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <Inchoo_Coreextended before="Mage_Customer_AccountController">
                            Inchoo_Coreextended_Frontend_Customer_AccountController
                        </Inchoo_Coreextended>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>
</config>

when I am trying to login than it display core login file not my module login and also can't shown any error and the value from my module. so please suggest me, what can i do.

Upvotes: 0

Views: 125

Answers (3)

Rohit Goel
Rohit Goel

Reputation: 3554

make this changes and it will fix the problem

  <config>
        <modules>
            <Inchoo_Coreextended>
                <active>true</active>
                <codepool>local</codepool>
            </Inchoo_Coreextended>
        </modules>
    </config>

after

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

codepool should be codePool

Upvotes: 1

huzefam
huzefam

Reputation: 1191

Check the below code

<?xml version="1.0"?>
<config>
    <modules>
        <Inchoo_Coreextended>
            <version>0.2.0</version>
        </Inchoo_Coreextended>
    </modules>
    <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <Inchoo_Coreextended before="Mage_Customer">
                            Inchoo_Coreextended_AccountController
                        </Inchoo_Coreextended>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>
</config>

and in your module make directory structure as

Inchoo
  /Coreextended
   /controllers
    /AccountController.php

and in the file make the class as

class Inchoo_Coreextended_AccountController extends Mage_Customer_AccountController

hope it helps!

Upvotes: 0

Marius
Marius

Reputation: 15216

Firs of all, this xml section:

<Inchoo_Coreextended before="Mage_Customer_AccountController">
    Inchoo_Coreextended_Frontend_Customer_AccountController
</Inchoo_Coreextended>

Should be

<Inchoo_Coreextended before="Mage_Customer">Inchoo_Coreextended</Inchoo_Coreextended>

Put it on one line, because Magento does not trim the xml nodes.

Then your class should be placed in

app/code/local/Inchoo/Coreextended/controllers/AccountController.php and it should be named Inchoo_Coreextended_AccountController.

The rest seams to be ok.

Upvotes: 0

Related Questions