Rewrite admin block that is rewriten by other extension

Rewrite admin block that is rewriten by other extension

October 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Rewrite admin block that is rewriten by other extension

Rewriting Magento Blocks: Solving Conflicts Between Extensions

Hey there,

Today we’re diving into a common issue many Magento developers face - trying to rewrite an admin block that’s already been rewritten by another extension. Let me walk you through the steps to solve this problem without breaking your existing setup.

The Challenge You’ve got two extensions, both aiming to modify the same admin block (sales_order_view). One is yours (let’s call it Bitstream_FancourierSelfawb), and the other belongs to a third-party developer (Fooman_EmailAttachments).

In your config.xml, you’re correctly setting up the rewrite:

<blocks>
    <adminhtml>
        <rewrite>
            <sales_order_view>Bitstream_FancourierSelfawb_Block_View</sales_order_view>
        </rewrite>
    </adminhtml>
    <bitstream_selfawb>
        <class>Bitstream_FancourierSelfawb_Block</class>
    </bitstream_selfawb>
</blocks>

You’ve even got the actual rewrite file in your Bitstream/FancourierSelfawb/Block directory. But when you try to add a new button, Fooman’s extension is blocking your changes.

Understanding The Conflict The issue lies in the fact that both extensions are trying to redefine the same block using the <rewrite> tag in their config.xml files. When Magento processes these configuration files during initialization, it prioritizes the last definition it encounters.

In this case, Fooman’s extension is included later in the app/code directory, so its rewrite takes precedence over yours.

Solving The Problem To resolve this conflict without directly commenting out or removing Fooman’s rewrite (which could break their module), you have a couple of options:

  1. Use a Unique Block Name Instead of trying to rewrite the same block (sales_order_view), you can create your own unique block and use it alongside Fooman’s.

    First, define your new block in app/code/Bitstream/FancourierSelfawb/etc/config.xml:

    <blocks>
        <bitstream_selfawb>
            <class>Bitstream_FancourierSelfawb_Block</class>
            <blocks>
                <custom_order_view>
                    <class>Bitstream_FancourierSelfawb_Block_CustomOrderView</class>
                </custom_order_view>
            </blocks>
        </bitstream_selfawb>
    </blocks>
    

    Then, create the actual block file: app/code/Bitstream/FancourierSelfawb/Block/CustomOrderView.php. Here’s a basic example:

    namespace Bitstream\FancourierSelfawb\Block;
    
    class CustomOrderView extends \Magento\Sales\Block\Adminhtml\Order\View
    {
        // Add your customizations here
    }
    
  2. Use Priority and Dependency If you want to stick with the same block name, you can use priority and dependency tags in your config.xml.

    <blocks>
        <adminhtml>
            <rewrite>
                <sales_order_view>Bitstream_FancourierSelfawb_Block_View</sales_order_view>
                <dependency>Fooman_EmailAttachments</dependency>
                <priority>100</priority>
            </rewrite>
        </adminhtml>
    </blocks>
    

    The priority attribute allows you to set the order of processing for your rewrite. A higher number means it will be processed first.

    The dependency attribute ensures that your module is initialized after Fooman’s, which can help avoid conflicts.

Conclusion: Playing Nice in the Magento Sandbox

In a perfect world, every Magento extension would play nicely together without rewriting core or other extension’s blocks. But we don’t live in a perfect world, and conflicts happen.

When faced with these situations, remember to:

  • Always try to use unique block names when possible.
  • Communicate with the authors of conflicting extensions to find a common solution that benefits all users.
  • Document your changes clearly to avoid confusion for other developers working on your project.

Remember, the key is to maintain flexibility and compatibility in your extension design. By following these best practices, you can ensure your work integrates seamlessly with other Magento extensions without causing unnecessary conflicts.

Stay tuned for more developer tips and tricks right here at Laravel Company. Until next time!

Extensions Admin Configuration Email

Our network