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>
Related
I have a custom module Permissions_Orders. Here is my code to override orders controller from base admin -
config.xml -
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orders before="Mage_Adminhtml">Orders_Adminhtml_Sales_OrderController</orders>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Permissions/Orders/controllers/Adminhtml/Sales/OrderController.php -
<?php
require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
class Permissions_Orders_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
{
----
}
but still it is calling from base controller. I am not sure, where I am wrong here. Any help is appreciated.
Your config.xml should look like below,
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orders before="Mage_Adminhtml">Permissions_Orders_Adminhtml</orders>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Notice the change in </orders> node.
In config.xml is enough to specify the namespace and module name where you want to extend the base adminhtml controllers.
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Namespace_Adminhtml before="Mage_Adminhtml">Namespace_Adminhtml</Namespace_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>
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/
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.
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>
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>