Basically you do not copy the core module to
app/code. You create a new module inside
app/code directory and use common extending technics to change core functionality. Inside your new module define sequence to the core module you extending, so it will load after the core module and won’t work if the core module is disabled.
If you need to change PHP class:
- Rewrite – point your new class to the core class and implement changes in it.
- Plugin – use before, around, after plugins for some functions and implement changes in those plugins.
- Observers – observe specific event and do some actions when those are fired (should not manipulate event data though).
If you need to change layout:
- Create new layout file with the same name as core layout – add your changes into it.
If you need to change template file:
- Create your new template file and use layout to point it to existing block.
If you need to change di.xml or other xml files:
- Add same xml’s into your module and use extending methods that’s specific to xml file.
Please, read more about extending Magento here:https://devdocs.magento.com/guides/v2.4/extension-dev-guide/bk-extension-dev-guide.html