Magento 1 - module controller not working

Magento 1 - module controller not working

August 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 1 - module controller not working

Solving Magento 1 Controller Routing Issues: A Comprehensive Guide

Are you struggling with a Magento 1 module where your controller action isn’t being properly routed? You’re not alone. In this post, we’ll dive deep into a common issue faced by developers - the infamous “404 Not Found” error when trying to access a custom controller.

Understanding the Problem: Magento’s Routing Mechanism

Before we jump into solving the issue, let’s first understand how Magento handles routing. By default, it uses the config.xml file located in your module directory to define routes for controllers.

In your case, you’ve correctly added a new router section (<dynamicproduct>) inside the <frontend> configuration block:

<frontend>
    <routers>
        <dynamicproduct>
            <use>standard</use>
            <args>
                <module>Waqasalieee_Dynamicproduct</module>
                <frontName>dynamicproduct</frontName>
            </args>
        </dynamicproduct>
    </routers>
</frontend>

This tells Magento to use the standard router for your Dynamicproduct module and set the front name as dynamicproduct.

Identifying the Issue: Configuration Mistakes

Based on the provided code, there seem to be a few potential issues that could cause the “404 Not Found” error:

  1. Incorrect Module Namespace: Ensure that the namespace in your configuration file matches exactly with the one used for your module name.

    In this case, you have Waqasalieee as the namespace, which should match perfectly with the module name.

  2. Controller Naming Convention: Magento follows a specific naming convention for controllers: <ModuleName>_<ControllerName>. It doesn’t recognize underscores as part of the controller name.

    Your controller is named IndexController.php, but based on your configuration, it should be renamed to Dynamicproduct_IndexController.php to match the front name and module setup.

Solving the Problem: Step-by-Step

Now let’s fix these issues to get your controller working:

1. Update Your Controller Name

Rename your controller file from IndexController.php to Dynamicproduct_IndexController.php:

local/Waqasalieee/Dynamicproduct/controllers/Dynamicproduct_IndexController.php

Your new file structure should look like this:

local/
└── Waqasalieee/
    └── Dynamicproduct/
        ├── etc/
        │   └── config.xml
        └── controllers/
            └── Dynamicproduct_IndexController.php

2. Update the Controller Content

Ensure your controller class name matches the filename:

class Waqasalieee_Dynamicproduct_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        die('Working in index action');
    }
}

3. Test Your Controller

Now, try accessing your controller using the updated URL:

http://localhost/magento_test/dynamicproduct/index/index

If everything is configured correctly, you should see the output “Working in index action”.

Troubleshooting Tips

If you’re still facing issues, here are some additional tips to help diagnose the problem:

  • Enable Module Developer Mode: In your Magento admin panel, navigate to System > Configuration > Advanced > Developer. Set “Enabled” to “Yes” and clear the cache.

  • Check Log Files: Look for any error messages or warnings in the system.log file located under /var/log/.

  • Validate XML Schemas: Ensure that your config.xml file is valid by running it through an XML validator tool.

Conclusion

In this post, we’ve explored a common challenge faced by Magento 1 module developers - the dreaded “404 Not Found” error when trying to access custom controllers. By understanding Magento’s routing mechanism and following best practices for configuration and naming conventions, you can effectively resolve these issues and get your controller working as expected.

Remember that proper debugging techniques, such as checking log files and enabling developer mode, can be invaluable tools in tracking down elusive errors like the one described here.

Happy coding, and feel free to explore more Magento development insights on Laravel Company’s blog.

Magento 1 Catalog Extensions Configuration

Our network