Magento 2 – Can’t Change Page Layout Columns with Override Layout File

magento2overrides

I am able to change the layout columns if I extend a page's layout file, but it won't work if I use an override layout file. What do you have to do to change a page's layout columns with an override?

The code that works with a layout extension, eg., in \app\design\frontend\MyVendor\Theme\Magento_Catalog\layout\catalog_product_view.xml is:

<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
</page>

But then if I add the layout="2columns-left part to an override file at \app\design\frontend\MyVendor\Theme\Magento_Catalog\layout\override\base\catalog_product_view.xml then the layout columns don't change. Is that not possible?

Best Answer

To override a page layout you should use page_layout directory instead of layout.

\app\design\frontend\MyVendor\Theme\Magento_Catalog\page_layout\override\base\catalog_product_view.xml

Related Topic