From the instructions at Alan's blog, I have added the router in my config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Clean_Integration>
<version>1.0.0</version>
</Clean_Integration>
</modules>
<admin>
<routers>
<wellnesscoach_app_redirect>
<use>admin</use>
<args>
<module>Clean_Integration</module>
<frontName>appsync</frontName>
</args>
</wellnesscoach_app_redirect>
</routers>
</admin>
</config>
And then I have my controller defined here app/code/local/Clean/Integration/Controllers/IndexController.php :
<?php
die('checkpoint1');
class Clean_Integration_IndexController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->_redirectUrl('/appointments/sync/backend/');
die('checkpoint2');
}
}
When I try to open this url, it goes to the frontend side and throws a 404.
What's causing magento to not pick up this admin router?
<?xml version="1.0"?>
<config>
<modules>
<Clean_Integration>
<version>1.0.0</version>
</Clean_Integration>
</modules>
<admin>
<routers>
<integration>
<use>admin</use>
<args>
<module>Clean_Integration</module>
<frontName>appsync</frontName>
</args>
</integration>
</routers>
</admin>
Should be lower case controllers
app/code/local/Clean/Integration/controllers/IndexController.php
You may also want to put this in Adminhtml folder so that you dont run into issue in the future if you want to add a frontend and a admin controller.
app/code/local/Clean/Integration/controllers/Adminhtml/IndexController.php
One mistake I see you made is putting the controller in a folder called 'Controllers' instead of 'controllers' (case mistake).
For future reference to anyone else with this problem:
If your controller does not use the standard name of IndexController.php, you will still need to name both the file name and the class name within using the ...Controller convention.
So, if your controller lives in the Adminhtml folder, name it ExtensionController.php and name the class within My_Module_Adminhtml_ExtensionController extends ...
Credit to goes to this excellent article. HTH.
Related
I am new to magneto. I have created a custom module for webservice. I have done forgotpassword functionality but i am getting 404 page.
My folder structure for controller file:
app/code/local/Blazedream/Oauth/controllers/Customer/AccountController
class Blazedream_Oauth_Customer_AccountController extends Mage_Customer_AccountController
{
public function forgotPasswordPostAction()
{
echo"hiiiii";exit;
}
}
My config file:
<?xml version="1.0"?>
<config>
<modules>
<Blazedream_Oauth>
<version>0.1.0</version>
</Blazedream_Oauth>
</modules>
<frontend>
<routers>
<oauth>
<use>standard</use>
<args>
<modules>
<Blazedream_Oauth before="Mage_Oauth">Blazedream_Oauth</Blazedream_Oauth>
</modules>
</args>
</oauth>
</routers>
</frontend>
</config>
My module is enabled.
My url to run the forgotPasswordPostAction
http://xxxxxxxxxx/xxxxxx/index.php/oauth/customer/account/forgotpasswordpost
I am getting 404 page, i dont know where i had done the mistake.
If i create a accountcontroller file without creating the customer folder inside controllers folder, Then it is executing and print "hiiiiiiiii"
but If i create folder, yhen it displays 404 page..
Can anyone help me to fix this issue?
If you want to use the "Customer" folder that please use below:
Blazedream_Oauth_Customer
<modules>
<Blazedream_Oauth before="Mage_Oauth">Blazedream_Oauth_Customer</Blazedream_Oauth>
</modules>
class Blazedream_Oauth_Customer_AccountController extends Mage_Customer_AccountController
{
// your code
}
I found the issue.
I used wrong url to run, the correct url is
http://xxxxxx/xxxxxxxx/index.php/oauth/customer_account/forgotpasswordpost
Thanks for everyone replies.
I tried the tutorial on http://www.satollo.net/magento-pdf-invoices-customer-dashboard/comment-page-1#comment-47565.
This allows a user to view invoices as PDF on the frontend of my Magento store. The problem is, when I click on the link which points to Pdfinvoice/index/invoices/order_id/5/ it shows a 404 error.
I registered the module as followed:
(renamed to module to Pdfinvoice to avoid conflict with another module)
<?xml version="1.0"?>
<config>
<modules>
<Pdfinvoice>
<active>true</active>
<codePool>local</codePool>
</Pdfinvoice>
</modules>
</config>
app/etc/modules/Pdfinvoice.xml
I am breaking my head over this.
Maybe the module isn't registered? I've tried googling it, but I can't get it to work.
Does anyone know a solution to this problem?
When you rename the module in the module definition xml, make sure you do the same with your local folder (app/code/local/Pdfinvoice), your config.xml:
app/code/local/Pdfinvoice/etc/config.xml
<config>
<modules>
<Pdfinvoice>
<version>1.0.0</version>
</Pdfinvoice>
</modules>
<frontend>
<routers>
<pdf>
<use>standard</use>
<args>
<module>Pdfinvoice</module>
<frontName>pdfinvoice</frontName>
</args>
</pdf>
</routers>
</frontend>
.. and your new controller:
app/code/local/Pdfinvoice/controllers/IndexController.php
<?php
class Pdfinvoice_IndexController extends Mage_Core_Controller_Front_Action {
public function invoicesAction() {
...
Works flawless, I installed the module in minutes.
I added admin controller.
This code works correct:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mycompany_mymodule>Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
</modules>
</args>
</adminhtml>
</routers>
</admin>
If I add before="Mage_Adminhtml" to mycompany_mymodule:
<mycompany_mymodule before="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
then it doesn't work - got 404 error.
1. What does this option do?
Also I looked throught Alans' Storm article: http://alanstorm.com/magento_admin_controllers
There are example:
<config>
<!-- ... -->
<admin>
<routers>
<the_name_of_this_element_is_not_important_it_should_be_unique>
<use>admin</use>
<args>
<module>Alanstormdotcom_Adminhelloworld</module>
<frontName>adminhelloworld</frontName>
</args>
</the_name_of_this_element_is_not_important_it_should_be_unique>
</routers>
</admin>
<!-- ... -->
</config>
2. What is the difference between these definitions?
It solved:
I found Mage_Core_Controller_Varien_Router_Standard class where collectRoutes() method is defined. It parses "after" and "before" parameters to order the modules.
This method is calling from Mage_Core_Controller_Varien_Router_Admin (started from init method in Mage_Core_Controller_Varien_Front).
So after I looked through match process in Mage_Core_Controller_Varien_Router_Standard.
After Mage_Core_Controller_Varien_Router_Standard debuging I understood my fault.
I used Index controller instead of MyModuleContoller.
Alan Storm defined controller which is not under the admin module (i.e. adminhtml). When I use first config - it works perfect because I defined new modules under the section adminhtml. In Alan's config I cannot add my module to adminhtml. I could override it but it is not correct because other modules under the adminhtml will be removed then.
This is correct code for menu under the adminhtml:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mycompany_mymodule after="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
</modules>
</args>
</adminhtml>
</routers>
</admin>
Inchoo also described this config here.
I am trying to overwrite a controller of an extension....that is overwriting the cart controller.
The extension currently overwriting the cart controller is:
Innoexts/Warehouse/controllers/Checkout/CartController.php
The config entry in the Innoexts module doing this is:
<frontend>
<routers>
<checkout>
<args>
<modules>
<Innoexts_Warehouse before="Mage_Checkout">Innoexts_Warehouse_Checkout</Innoexts_Warehouse>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
The top of the innoext cartcontroller file is:
require_once 'Mage/Checkout/controllers/CartController.php';
class Innoexts_Warehouse_Checkout_CartController extends Mage_Checkout_CartController {
I want to overwrite it with this controller:
Myco/Warehousemod/controllers/Checkout/CartController.php
The top of the controller file is:
require_once 'Innoexts/Warehouse/controllers/Checkout/CartController.php';
class Myco_Warehousemod_Checkout_CartController extends Innoexts_Warehouse_Checkout_CartController {
The config entry ive created is:
<global>
...blah...blah...
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
</global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse_Checkout">Myco_Warehousemod_Checkout</Myco_Warehousemod>
</modules>
</args>
</checkout>
</routers>
...blah...blah...
</frontend>
I am getting a 404 not found error for the checkout/cart URL now....Can anyone see where im going wrong? Online resources are very different...and confusing!! The issue may be with me trying to overwrite an overwriting controller...??
thanks in advance...
Need to remove the first rewrite:
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
I think certain people should stop writing tutorials....cluttering up the web with their half-assed SEO efforts....
This part was used in the old versions of Magento (i think before 1.4), but if you want to extend a controller that has a rewrite like this in the config file, you have to do the same in your config.
<rewrite>
<myco_warehousemod_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<to>/warehousemod/checkout_cart/</to>
</myco_warehousemod_checkout_cart>
</rewrite>
The new versions use only the part with before so you should have something like this:
<routers>
<checkout>
<args>
<modules>
<Myco_Warehousemod before="Innoexts_Warehouse">Myco_Warehousemod_Checkout</Myco_Warehousemod><!-- just the name of the module Innoexts_Warehouse the overridden folder will be taken from the part after the name of your module so Magento will look in app/local/Myco/Warehousemod/controllers/Checkout/* and load all the controllers from there -->
</modules>
</args>
</checkout>
</routers>
Just an additional notes for those who wants to know about confliction between extensions and possible solutions(just like above case), refer to the following links:
http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/
http://sweettoothrewards.com/wiki/index.php/Resolving_extension_conflicts
http://magebase.com/magento-tutorials/magento-extension-clashes-winners-and-loosers/
http://www.magestore.com/blog/2011/12/21/magento-methods-to-resolve-the-module-conflicts-in-magento/
This is a little notification on the include path of the controller.
This include path can cause errors if the Magento Compiler mode is turned on.
require_once 'Mage/Checkout/controllers/CartController.php';
Instead of that it is good to use
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'CartController.php';
It will be safer.
Simply put, I want to override ProcessController which is in the Mage/Index/controllers/Admninhtml/ProcessController.php.
I know how to override the front-end controller, but this gives me a headache for hours now. I can't put it to work. Here's my config file
<?xml version="1.0"?>
<config>
<global>
<models>
<twobuy_index>
<class>Twobuy_Index_Model</class>
</twobuy_index>
</models>
</global>
<admin>
<routers>
<index>
<args>
<modules>
<Twobuy before="Mage_Index">Twobuy_Index</Twobuy>
</modules>
</args>
</index>
</routers>
</admin>
</config>
And the controller declaration
include_once('Mage/Index/controllers/Adminhtml/ProcessController.php');
class Twobuy_Index_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController
{
I tried overriding reindexAction, but my method never gets called.
Replace <index> with <adminhtml> in your config file. It might just be a copy-paste error but your <Twobuy> tag is incorrectly ended with </Ucon>.
<Twobuy before="Mage_Index">Twobuy_Index</Ucon>
Looks like an error in your XML
<twobuy_index before="Mage_Index">Twobuy_Index</twobuy_index>