Changing a layout XML of a Magento 2 module

In order to customize the layout to your own requirements, you can just add it to your theme and make the required changes. In order to change a layout from a Magento 2 module, you will need to locate the module and layout handle that you want to alter.

Getting ready

In this recipe, we will change the order of some elements on the product view page based on the theme created in the previous recipe.

How to do it…

The following steps will show you how to change elements defined in a layout file to match your desired design:

  1. Create the layout handle file for the Magento_Catalog module:

    app/design/frontend/Genmato/default/Magento_Catalog/layout/catalog_product_view.xml

    <?xml version="1.0"?> <page layout="1column" ...

Get Magento 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.