Overriding account controller - magento

I try to override function in controller /app/code/core/Mage/Customer/controllers/AccountController.php.
I create module folders:
/app/code/local/Mandarin/SkipLogoutSuccess/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<version>0.1.0</version>
</Mandarin_SkipLogoutSuccess>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<mandarin_skiplogoutsuccess before="Mage_Customer">Mandarin_SkipLogoutSuccess</mandarin_skiplogoutsuccess>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
/app/code/local/Mandarin/SkipLogoutSuccess/controllers/AccountController.php
require_once 'Mage/Customer/controllers/AccountController.php';
class Mandarin_SkipLogoutSuccess_AccountController extends Mage_Customer_AccountController
{
public function logoutAction()
{
$this->_getSession()->logout()->setBeforeAuthUrl(Mage::getUrl());
Mage::log("its Allive!", null, 'mygento.log');
$this->_redirectUrl(Mage::getUrl());
}
}
/app/etc/modules/Mandarin_SkipLogoutSuccess.xml
<?xml version="1.0"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<active>true</active>
<codePool>local</codePool>
</Mandarin_SkipLogoutSuccess>
</modules>
</config>
When I run logoutAction controller is used from core. In my log file I don`t get message.
Where could be the error?

I think you made a copy-paste error:
In your config.xml you reference the namespace "<checkout>" but it should be "<customer>" (and of course the closing tag too)

In your config.xml
<frontend>
<routers>
<customer> <!-- should be customer -->
And in Mandarin_SkipLogoutSuccess.xml
<?xml version="1.0"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Customer /> <!-- Make sure this is loaded first -->
</depends>
</Mandarin_SkipLogoutSuccess>
</modules>
</config>

Related

Magento 1: app/code/local not overriding core file

I have copied the "app/code/core/Mage/Customer/controllers/AccountController.php" to "app/code/local/Mage/Customer/controllers/AccountController.php" but it is not overriding the targeted file. what is getting wrong?
Create following files:
1) app/etc/modules/Muk_Account.xml
<?xml version="1.0"?>
<config>
<modules>
<Muk_Account>
<active>true</active>
<codePool>local</codePool>
</Muk_Account>
</modules>
</config>
2) app\code\local\Muk\Account\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Muk_Account>
<version>0.1.0</version>
</Muk_Account>
</modules>
<frontend>
<routers>
<customer>
<use>standard</use>
<args>
<modules>
<Muk_Account before="Mage_Customer">Muk_Account_Customer</Muk_Account>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
3) app\code\local\Muk\Account\controllers\Customer\AccountController.php
<?php
require_once 'Mage/Customer/controllers/AccountController.php';
class Muk_Account_Customer_AccountController extends Mage_Customer_AccountController
{
public function createPostAction()
{
}
}

Magento : Create admin module

I have a problem. I following guideline but it doesn't work. I don't know debug how. Please tell me the way resolve problem.
This is HS_Imagepro.xml in etc/modules/ folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<active>True</active>
<codePool>core</codePool>
</HS_Imagepro>
</modules>
</config>
This is config.xml in HS/Imagepro/etc folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<module>HS_Imagepro</module>
<frontName>imagepro</frontName>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<menu>
<imagepro_menu translate="title" module="imagepro">
<title>ImagePro</title>
<sort_order>9999</sort_order>
<children>
<first_page module="imagepro">
<title>Our First Page</title>
<action>imagepro/index/index</action>
</first_page>
</children>
</imagepro_menu>
</menu>
</adminhtml>
<global>
<helpers>
<imagepro>
<class>HS_Imagepro_Helper</class>
</imagepro>
</helpers>
</global>
</config>
This is IndexController.php in HS/Imagepro/controllers/
<?php
class HS_Imagepro_IndexController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
The result is the page not found.
If The following right guideline, access link http://localhost/magento/index.php/imagepro/ will appear admin login screen.
In ,HS_Imagepro.xml file the test TRUE Should be true.
routing code Wrong in config.xml
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<!-- Includes our controller, so when we add the adminhtml menu item below, it is found! -->
<adminhtml>
<args>
<modules>
<imagepro before="Mage_Adminhtml">HS_Imagepro_Adminhtml</imagepro>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Also controller file and path name is wrong
HS/Imagepro/controllers/Adminhtml/ImageproController.php
<?php
class HS_Imagepro_Adminhtml_ImageproController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
Testing url yourhost/magento/index.php/admin/imagepro
More details on http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table#directory_additions
and frontend module http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/

setting a route for magento new module

i have registered a new module
cd /path/to/store/app
touch etc/modules/Maticode_WebLog.xml
<?xml version="1.0"?>
<config>
<modules>
<Maticode_WebLog>
<active>true</active>
<codePool>local</codePool>
</Maticode_WebLog>
</modules>
</config>
add this config file:
touch app/code/local/Maticode/WebLog/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Maticode_WebLog>
<version>
0.1.0
</version>
</Maticode_WebLog>
</modules>
<frontend>
<routers>
<weblog>
<use>standard</use>
<args>
<module>Maticode_WebLog</module>
<frontName>weblog</frontName>
</args>
</weblog>
</routers>
</frontend>
</config>
clear the cache (backoffice:system/cache management:disable all),
add a controller to it
touch app/code/local/Maticode/WebLog/controllers/IndexController.php
<?php
class Maticode_WebLog_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction(){
echo "indexaction";
// $this->loadLayout();
// $this->renderLayout();
}
public function testModelAction() {
echo 'Setup!';
}
}
this url :
http://localhost/magento/weblog
or http://localhost/magento/index.php/weblog/
returns 404 error , why??
my Maticode_WebLog.xml was wrong.
This is the correct one:
<?xml version="1.0"?>
<config>
<modules>
<Maticode_WebLog>
<active>true</active>
<codePool>local</codePool>
</Maticode_WebLog>
</modules>
</config>

I want to know why my Magento Module with only controllers is not working

This is my activation file,
in app/etc/modules/My_Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Test>
<active>true</active>
<codePool>local</codePool>
</My_Test>
</modules>
</config>
This is my config file in app/code/local/MY/Test/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<helpers>
<my_test>
<class>My_Test_Helper</class>
</my_test>
</helpers>
<models>
<mytest>
<class>My_Test_Model</class>
</my_test>
</models>
<blocks>
<my_test>
<class>My_Test_Block</class>
</my_test>
</blocks>
</global>
<frontend>
<routers>
<my_test>
<use>standard</use>
<args>
<module>My_Test</module>
<frontName>test</frontName>
</args>
</my_test>
</routers>
</frontend>
</config>
This is my controllers code
in app/core/local/My/Test/controllers/IndexController.php
<?php
class My_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "This is the Module MyTest";
}
}
Now when i am giving the url
176.58.99.99/herbal/index.php/test/index/index
176.58.99.99/herbal/index.php/test/
176.58.99.99/herbal/test/index/index
176.58.99.99/herbal/test/
Its showing 404 error
You say your controller is located in app/core/local/My/Test/controllers/IndexController.php while it should be placed as followed: app/code/local/My/Test/controllers/IndexController.php
I had the same problem, but in my case it was about file permissions. Make sure that your files and directories have the proper access permissions, if not, magento will never be able to read those files.

Magento - local cartcontroller is not working

I'm trying to overwrite the function couponPostAction in Magento, which is in the cartcontroller.
I created a new local Module Nf_Ajaxcoupon.
this is the config file
<?xml version="1.0"?>
<config>
<modules>
<Nf_Ajaxcoupon>
<version>0.1.0</version>
</Nf_Ajaxcoupon>
</modules>
<global>
<rewrite>
<Nf_Ajaxcoupon_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/Ajaxcoupon/checkout_cart/</to>
</Nf_Ajaxcoupon_checkout_cart>
</rewrite>
</global>
<frontend>
<routers>
<Nf_Ajaxcoupon>
<use>standard</use>
<args>
<module>Nf_Ajaxcoupon</module>
<frontName>Ajaxcoupon</frontName>
</args>
</Nf_Ajaxcoupon>
</routers>
</frontend>
</config>
This is my module activation:
<?xml version="1.0"?>
<config>
<modules>
<Nf_All>
<active>true</active>
<codePool>local</codePool>
</Nf_All>
</modules>
</config>
This is my CartController.php file:
<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Nf_Ajaxcoupon_Checkout_CartController extends Mage_Checkout_CartController
{
function couponPostAction()
{
var_dump($_POST);
die('local');
}
}
?>
I can't understand why its not calling the local controller, when I go to system->configuration->advanced I see it is enabled.
Any suggestions why its not working or ways to debug it?
Thanks
This is the proper way to override a controller in config inside frontend node
<routers>
<checkout>
<args>
<modules>
<Nf_Ajaxcoupon before="Mage_Checkout">Nf_Ajaxcoupon_Checkout</Nf_Ajaxcoupon>
</modules>
</args>
</checkout>
</routers>
also are you sure that your configure file would not need to be for Nf_Ajaxcoupon not to Nf_All
<?xml version="1.0"?>
<config>
<modules>
<Nf_Ajaxcoupon>
<active>true</active>
<codePool>local</codePool>
</Nf_Ajaxcoupon>
</modules>
</config>

Resources