Magento Admin Customer Edit Tabs

Magento Admin Customer Edit Tabs

October 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Admin Customer Edit Tabs

Redirecting Magento Admin Customer Edit Tabs After Saving

Magento allows you to extend its admin functionality using custom tabs on the customer edit page. Recently, one of our developers encountered an issue where after saving data in a custom tab (Customer Notes), the system would redirect back to the default “Customer View” tab instead of staying on the “Customer Notes” tab.

The Controller Issue

The developer had written a controller that successfully saved data into the database upon submission. However, the redirection behavior was not as expected. Here’s the relevant part of the controller code:

public function saveAction()
{
    // Database write operations here...

    $this->_redirectReferer();
}

The _redirectReferer() method is a Magento core function that redirects back to the page that made the request, which in this case was the default “Customer View” tab.

Achieving the Desired Behavior

To make the system redirect to the desired tab after saving, you need to manually manage the redirection URL. Here’s how we resolved the issue:

  1. Instead of using $this->_redirectReferer(), create your own redirection code.
  2. Get the current customer ID and append it to the redirection URL.
  3. Redirect to the new URL.

Here’s the updated saveAction() method:

public function saveAction()
{
    // Database write operations here...

    $customerId = Mage::registry('current_customer')->getId();
    $url = $this->getUrl('adminhtml/customer/edit', array('id' => $customerId));

    $this->_redirect($url);
}

In the code above, Mage::registry('current_customer') retrieves the current customer object. We then extract the customer ID and use it to construct the redirection URL.

Configuring Your Custom Module

For your custom module to work properly, you need to configure your config.xml file correctly. Here’s an example of a correctly configured config.xml:

<admin>
    <routers>
        <customernotes>
            <use>admin</use>
            <args>
                <module>Mycompany_Customernotes</module>
                <frontName>customernotes</frontName>
            </args>
        </customernotes>
    </routers>
</admin>

In this configuration, we define a new router called “customernotes” that uses the admin controller and specifies our custom module as “Mycompany_Customernotes”. The frontName is set to “customernotes”, which corresponds to the front name used in the URL.

Conclusion

Redirecting to specific tabs after saving data requires manual manipulation of the redirection URL. By extracting the customer ID and constructing the new URL, we were able to achieve the desired behavior—returning to the “Customer Notes” tab after a successful save operation.

Remember that this solution assumes you have already set up your custom module correctly and integrated it into Magento. If you’re having trouble with the integration or need further assistance, feel free to reach out to our team at https://laravelcompany.com for professional help.

Happy coding!

Database Admin Customers Errors

Our network