Overwrite CompareController - magento

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>

Related

Magento Checkout OnepageController not getting override

I have searched and implemented many answers from stackoverflow but I am not able to override the controller. The question is quite self-explanatory but I will provide the codes to show what I am doing. Maybe someone can guide me in the right direction:
This is my directory structure
This is my config.xml inside etc folder.
<?xml version="1.0"?>
<config>
<modules>
<Zepcom_Checkout>
<version>0.0.1</version>
</Zepcom_Checkout>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Zepcom_Checkout before="Mage_Checkout">Zepcom_Checkout</Zepcom_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
And this is my controller
require_once 'Mage/Checkout/controllers/OnepageController.php';
class Zepcom_Checkout_OnepageController extends Mage_Checkout_OnepageController {
public function indexAction() {
var_dump("custom"); die;
}
.
. // some overriding code here
.
}
I am really stuck and any help would be appreciated. I am doing a dump to verify the calling of the controller but it keeps calling the Core controller.
You will need to declare a router "routeurfrontend" which is actually the route used by Magento to access your controller.
<?xml version="1.0"?>
<config>
<frontend>
<routers>
<zepcom_checkout>
<use>standard</use>
<args>
<module>Zepcom_Checkout</module>
<frontName>zepcom_checkout</frontName>
</args>
</zepcom_checkout>
<checkout>
<args>
<modules>
<Zepcom_Checkout before="Mage_Checkout">Zepcom_Checkout</Zepcom_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
You are missing the </config> closing tag in your config.xml
<?xml version="1.0"?>
<config>
<modules>
<Zepcom_Checkout>
<version>0.0.1</version>
</Zepcom_Checkout>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Zepcom_Checkout before="Mage_Checkout">Zepcom_Checkout</Zepcom_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>

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

not load controller in magento, why?

config.xml
<?xml version="1.0"?>
<config>
<modules>
<Asgard_New>
<version>1.6.0.0</version>
</Asgard_New>
</modules>
<global>
<models>
<asgardnew>
<class>Asgard_New_Model</class>
</asgardnew>
</models>
<helpers>
<asgardnew>
<class>Asgard_New_Helper</class>
</asgardnew>
</helpers>
</global>
<frontend>
<routers>
<asgardnew>
<use>standard</use>
<args>
<module>Asgard_New</module>
<frontName>new</frontName>
</args>
</asgardnew>
</routers>
</frontend>
</config>
Asgard_New.xml
<?xml version="1.0"?>
<config>
<modules>
<Asgard_New>
<active>true</active>
<codePool>local</codePool>
</Asgard_New>
</modules>
</config>
IndexController.php
<?php
class Asgard_New_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "Hello, magento!!";
}
public function helloAction()
{
echo "Hello, action!!";
}
public function layoutAction()
{
$xml = $this->loadLayout()->getLayout()->getUpdate()->asString();
$this->getResponse()->setHeader("Content-Type", "text/plain")->setBody($xml);
Mage::log($xml, Zend_Log::INFO, 'layout_log', true);
}
public function defaultAction()
{
$this->loadLayout()->renderLayout();
}
}
?>
Modul -> local/Asgard I have folders with same code Test ans New
http://magento/test/index/index
http://magento/new/index/index
Not work, last two days works, but today i try created a own package and theme this is stop working. Why its may happened, guys? Thanks!
Try to replace asgardnew with new
<frontend>
<routers>
<new>
<use>standard</use>
<args>
<module>Asgard_New</module>
<frontName>new</frontName>
</args>
</new>
</routers>
</frontend>

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>

Resources