Magento: How can we override Enterprise files (Enterprise Edition)?

Magento: How can we override Enterprise files (Enterprise Edition)?

September 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: How can we override Enterprise files (Enterprise Edition)?

Override Enterprise Class Files in Magento

As an experienced developer working with enterprise-level e-commerce platforms like Magento, you might often need to override or rewrite class files that come bundled with the Enterprise Edition. This is especially true when you want to extend core functionality without modifying the original files directly.

The key to successfully overriding Enterprise classes lies in understanding Magento’s autoload mechanism and its plugin system introduced in version 2.0. Let me walk you through a step-by-step guide on how to achieve this effectively.

Step 1: Understand the File Structure

First, let’s understand where your custom code needs to be placed. Magento uses the app/code directory for all customizations. Within this folder, create a new module using the following structure:

app/code/YourVendorName/YourModuleName

Replace YourVendorName and YourModuleName with your actual vendor name and desired module name.

Step 2: Create the Plugin File

Next, you need to create a plugin file that will intercept and extend the behavior of the Enterprise class you want to modify. This is done using XML configuration files located in app/code/YourVendorName/YourModuleName/etc.

Create an etc folder if it doesn’t exist already. Inside this folder, create two files:

  1. module.xml: This file contains basic module information.

  2. di.xml: This file defines the plugin you want to create.

Here’s what a typical di.xml file looks like for overriding an Enterprise class:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:magento:module:Magento_Store:etc/di.xsd">
    <type name="Magento\Catalog\Model\Product\Visibility">
        <plugin name="your_vendor_your_module::visibility"
                type="YourVendorName\YourModuleName\Model\Plugin\CatalogModelProductVisibility"/>
    </type>
</config>

Replace Magento\Catalog\Model\Product\Visibility with the fully qualified class name of the Enterprise class you want to override. In this example, we’re overriding the product visibility class from Magento’s core Catalog module.

Step 3: Create the Plugin Class

Now, create the actual plugin class that will be called whenever your specified class is instantiated or executed. This class should be located in app/code/YourVendorName/YourModuleName/Model/Plugin.

Here’s a simple example of what this class might look like:

<?php

namespace YourVendorName\YourModuleName\Model\Plugin;

class CatalogModelProductVisibility
{
    public function aroundGetVisibleOnCatalog($subject, $proceed)
    {
        // Your custom logic here
        return $proceed();
    }
}

In this example, the aroundGetVisibleOnCatalog method is a wrapper for the core getVisibleOnCatalog method. It allows you to add or modify functionality before calling the original method.

Step 4: Enable and Apply Changes

To apply these changes, compile your Magento code using the command:

php bin/magento setup:di:compile

This tells Magento to process all the XML configuration files and generate the necessary autoload information.

That’s it! You have now successfully overridden an Enterprise class in Magento without directly modifying any core files. This approach ensures that your changes are isolated from the main codebase, making them easier to maintain and update during Magento upgrades.

Remember, when working with Enterprise Edition, always keep an eye on the Magento official documentation for the latest best practices and guidelines.

Don’t forget to check out our comprehensive guides on Magento development at Laravel Company’s Magento Blog. We cover everything from basic setup to advanced customizations like this one.

Happy coding, and feel free to reach out if you have any further questions!

Extensions Configuration

Our network