How to modify / extend a module in Magento 2 ?
To modify or extend a Magento 2 module, always create your own custom module that extends the original instead of editing the vendor code.
Why this approach?
- Keeps the original module unmodified, so you can upgrade to future versions without losing your changes.
- Lets you override layouts/templates and extend classes cleanly via Magento’s dependency injection and layout systems.
Example: Extending the Quick View extension
If you want to customize the Quick View extension, create a new module such as Quickview_Custom.
Apply your changes inside this custom module only, leaving the original Quick View extension untouched.
What you can customize in your custom module
- Layout & view files: override XML, PHTML, and static assets to adjust structure and styles.
- Dependency Injection (DI): use preferences, plugins, or virtual types to extend PHP classes.
- Observers & events: listen to Magento events to add or change behavior.
- Routes & controllers: add endpoints or tweak request handling where needed.
Keep your overrides as minimal and targeted as possible to reduce maintenance effort during upgrades.
Recommended reading
More detailed examples for overriding CSS / XML / PHTML / JS in Magento 2:
[How to customize css / xml / phtml / js files in Magento 2 - examples Tutorial ]
Updated on: 16/09/2025
Thank you!
