> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.weltpixel.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 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 ]](https://help.weltpixel.com/en/article/how-to-customize-css-xml-phtml-js-files-in-magento-2-examples-tutorial-14jmrvm/?bust=1758010336141)