Magento 2 – editing module structure and functions

The question:

in Magento 1.x you could duplicate the extensions to app/design/frontend/themeName/default/template/or/layout and then modify it’s layout or functionality via xml or phtml files.

How do we duplicate and edit certain modules now in M2? I have looked over the docs but couldn’t find this info. For example i wish to edit phtml of module-catalog/view/frontend/templates/product/gallery.phtml correct way by having theme based module overwrite and now edit core modules within vendor/magento*/ folder.

Thanks for the help.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

With version 2.0.0 release(not Github), You should do as below

Copy templates need to make override in:

vendor/magento/<module_name>/view/frontend/templates

Location contain templates using to override:

app/design/frontend/<Vendor_Theme>/<name_theme>/Magento_<module_name>/templates

Example

You want override a template in: vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

You create a file have path as: app/design/frontend/<Vendor_Theme>/<name_theme>/Magento_Catalog/templates/product/list.phtml


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment