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

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()
{
}
}

Related

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>

Overriding account controller

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>

creating a module helloworld magento

I followed the tutorial in http://alanstorm.com/magento_controller_hello_world
but I don't know why the link filipeferminiano.com/lojateste/helloworld does't works.
Here is my config.xml
<config>
<modules>
<ffdotcom_Helloworld>
<version>0.1.0</version>
</ffdotcom_Helloworld>
</modules> <frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>ffdotcom_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
Create: app/code/local/Ffdotcom/Helloworld/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Ffdotcom_Helloworld>
<version>1.0.0</version>
</Ffdotcom_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Ffdotcom_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
Create: app/code/local/Ffdotcom/Helloworld/controllers/IndexController.php
<?php
class Ffdotcom_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction(){
echo 'hello world';
}
}
Create: app/etc/modules/Ffdotcom_Helloworld.xml
<?xml version="1.0"?>
<config>
<modules>
<Ffdotcom_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Ffdotcom_Helloworld>
</modules>
</config>
The first "f" in your module name must be capitalized in the frontend/routers/helloworld/args xpath.

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>

Overwrite CompareController

I try to override the Core CompareController. Somehow i don't get it done.
I have done some research on the Magento website: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller
But it did not help override the controller.
local/WP/Compare/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<WP_Compare>
<version>0.1.0</version>
</WP_Compare>
</modules>
<global>
<rewrite>
<WP_Compare_Catalog_Product_Compare>
<from><![CDATA[#^/catalog/product/compare/#]]></from>
<to>/compare/catalog/product/compare/</to>
</WP_Compare_Catalog_Product_Compare>
</rewrite>
</global>
</config>
local/WP/Catalog/controllers/Product/CompareController.php
<?php
require_once "Mage/Catalog/controllers/Product/CompareController.php";
class WP_Compare_Catalog_Product_CompareController extends Mage_Catalog_Product_CompareController
{
public function addAction()
{
echo 'Lets GO!';
}
}
?>
Can someone help me with this issue?
Thank you.
Gr.
Lex
This is the solution for my problem.
<?xml version="1.0"?>
<config>
<modules>
<WP_Compare>
<version>0.1.0</version>
</WP_Compare>
</modules>
<frontend>
<routers>
<catalog>
<use>standard</use>
<args>
<modules>
<WP_Compare before="Mage_Catalog">WP_Compare_Catalog</WP_Compare>
</modules>
</args>
</catalog>
</routers>
</frontend>
</config>
You may be need to do something similar to that into your etc.xml:
<frontend>
<routers>
<customer>
<args>
<modules>
<Mymodule_Customer before="Mage_Customer">Mymodule_Customer</Mymodule_Customer>
</modules>
</args>
</customer>
</routers>
</frontend>

Resources