Magento config XML for adding a controller action to a core admin controller

Magento config XML for adding a controller action to a core admin controller

September 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento config XML for adding a controller action to a core admin controller

Adding Custom Actions to Core Admin Controllers in Magento

As a senior developer working on a Magento project, you might find yourself needing to extend core admin controllers to add custom functionality. This is particularly useful when you want to enhance the default features without modifying the core directly.

The scenario described involves extending the Mage_Adminhtml_Catalog_ProductController to add a new action. Let’s dive into the correct approach for this in Magento 1.x, which still has significant user base due to its stability and extensive feature set.

Understanding Mage Rewrite

You’ve correctly identified that you need to use the <rewrite> node in the config.xml file to redirect requests from the core controller action to your extended version. The <from> attribute contains a regular expression matching the URL pattern, while the <to> attribute specifies the new path.

Identifying the Issue

Your XML configuration seems logically correct based on the provided code snippet:

<mycompany_mymodule_catalog_product>
    <from><![CDATA[#^/catalog_product/massAttributeSet/#]]></from>
    <to>/mymodule/catalog_product/massAttributeSet/</to>
</mycompany_mymodule_catalog_product>

However, the issue lies not in the XML syntax itself but rather in how Magento processes controller actions. In your current setup, you are rewriting an existing action (massAttributeSet), which isn’t actually implemented by the core Mage_Adminhtml_Catalog_ProductController. As a result, even though you’ve extended the class, there’s no original method to redirect from.

The Correct Approach

To add a custom action to a core controller, you need to create an entirely new route and handle it separately. Here’s how you can do this:

  1. Create a New Router: Define a new router within your module configuration file for the admin section.
<global>
    <admin>
        <routers>
            <MyCompany_MyModule_MassAttributeSet>
                <use>admin</use>
                <args>
                    <module>MyCompany_MyModule</module>
                    <frontName>massattributeset</frontName>
                </args>
            </MyCompany_MyModule_MassAttributeSet>
        </routers>
    </admin>
</global>
  1. Handle the Action: In your module, create a new controller Mymodule/Controller/Adminhtml/MassattributeSet.php and implement the desired logic.

  2. Update the Rewrite: Modify your rewrite rule to point to this new router.

<mycompany_mymodule_massattributeset>
    <from><![CDATA[#^/massattributeset/massAttributeSet/#]]></from>
    <to>/mymodule/catalog_product/massAttributeSet/</to>
</mycompany_mymodule_massattributeset>

Best Practices

When extending core controllers, always ensure:

  • You are using the correct version of Magento.
  • Your module is enabled and active in the system.
  • The controller class name matches exactly with the routing configuration.

Remember to clear your cache after making changes to the config.xml file for the changes to take effect. If you’re still experiencing issues, double-check that all paths are correctly defined and that the controller logic is implemented as expected.

Conclusion

Adding custom actions to core admin controllers in Magento involves understanding how routing works and how to create new routes to handle extended functionality. Always aim to keep your customizations separate from the core code for better maintainability and upgrade compatibility. For more advanced techniques and best practices, I recommend exploring the official Magento developer documentation at laravelcompany.com.

Magento 1 Catalog Extensions Admin

Our network