

How to Make Changes in Magento’s Core Functionality Without Touching its Core


Listen Full Blog Here
Key Takeaways
- »Magento plugins provide the recommended approach for extending Magento core functionality.
- »Events and observers enable developers to customize Magento workflows without modifying core files.
- »Magento preferences allow class overrides when plugins and observers cannot meet specific requirements.
- »Avoiding Magento core modifications ensures smoother upgrades and long-term maintainability.
- »Understanding Magento extension mechanisms helps developers build scalable Adobe Commerce solutions.
- »Following Magento development best practices improves code quality, flexibility, and platform stability.
Magento handles its data in a specific way as per the models and modules in its functionality.
Sometimes there might be a need to change the way this data is handled or displayed for any reason
or scenario whatsoever. Changing the Magento’s core directly is a bad practice in such cases because these changes made in the core would seize to exist when the Magento is upgraded and all the
changes would be lost for further use.
Certain ways to change Magento’s core functionality without altering the files in its core folder are:
- Plugins
- Events and observers
- Preferences
‘Plugins’ are the best way to make changes in Magento functionality. Although in some cases these
Magento Plugins do not prove to be useful, hence in such cases we use ‘Events and Observers’. In the scenarios where both Plugins and Events and Observers fail to solve the purpose, ‘Preferences’ are
used.
Plugins
Plugins were introduced in Magento 2 and did not exist in Magento 1. Plugins can be utilized for all classes but only for changing public methods. Protected and private methods cannot be modified
using Plugins. There are three types of Magento Plugins which are provided in Magento and they are:
- Before – executed right before the actual function that needs to be modified
- After – executed right after the actual function that needs to be modified
- Around – executed both before and after the actual function that needs to be modified. It
has a callable method, where it takes a callable variable as a parameter. This variable denotes the function that is being treated. Each time this parameter is called, it returns the
function it denotes.
Events and observers
Events and observers are a way to intercept Magento’s flow by observing the events that the Magento triggers. Observers are hooked to events in the Magento Functionality, for example, customer login. These can be used to do changes in such events, like, we can write a function for shooting an e-mail to the customer each time they log in, etc.
Preferences
Preferences in Magento 2 are similar to the rewrites in Magento
1. Preferences are used to substitute an instance of a class with another instance. It is basically used to call a substitute class instead of the original class asked for. This substitute class is the one where all the changes in functionality are done without changing anything in the original class.
Extending Magento the Right Way
Customizing Magento without modifying its core is essential for building secure, scalable, and upgrade-friendly Adobe Commerce solutions. By leveraging plugins, events and observers, and preferences appropriately, developers can extend Magento's functionality while preserving platform stability and simplifying future updates. Following Magento development best practices not only improves maintainability but also ensures customizations remain compatible as your eCommerce store evolves.
Optimize your Adobe Commerce (Magento) solutions with Codilar Technologies.
FAQs
Modifying Magento core files can cause customizations to be overwritten during upgrades, making future maintenance difficult and increasing the risk of compatibility issues. Magento recommends extending functionality through plugins, events, observers, and preferences instead.
Magento plugins are extension mechanisms that allow developers to intercept and modify the behavior of public class methods without changing the original source code. They support before, after, and around method execution.
Events and observers are useful when responding to specific Magento events, such as customer registration or order placement. They enable developers to execute custom business logic without directly modifying Magento core functionality.
Magento preferences allow developers to replace one class with another using dependency injection. They should be used carefully, typically when plugins or events and observers cannot achieve the required customization.
The recommended approach is to use plugins whenever possible, followed by events and observers for event-driven customizations. Preferences should be reserved for scenarios where other extension mechanisms are not suitable, helping maintain a scalable and upgrade-safe Magento architecture.

eRetail Growth
in Mind?
Get tailored technology solutions to scale your retail business online
Request A Quote
Subscribe to
Stay in Know
Stay ahead with insights, trends, and brand success stories from the world of Digital Commerce.






