Magento 2 – Force Product View Layout to 1 Column

magento-2.1.3magento2page-layouts

I want to show the single product page information in one single column, but it is always displayed on 2-columns-left:

<body data-container="body" itemtype="http://schema.org/Product" itemscope="itemscope" class="page-product-configurable catalog-product-view product-e16-mariniere-cannes page-layout-2columns-left">

I have in app/design/frontend/mycompany/mytheme/Magento_Catalog/layout/catalog_product_view.xml configured the page in 1column

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

But still displaying the 2 columns layout, with the product info on the right, and a blank column on the left.

I added

<referenceContainer name="content.aside" remove="true" />

And now the left column is not there, but still the product is moved to the right as if the column is still there.

When I edit this xml file, the changes are displayed, so the file is placed correctly, and it is being readed. But still 2 columns left layout.

I even tried with no result the following approach:

<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>

This is the full content file:

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <css src="mage/gallery/gallery.css"/>
</head>
<update handle="catalog_product_opengraph" />
<update handle="page_calendar"/>
<body>
    <attribute name="itemtype" value="http://schema.org/Product" />
    <attribute name="itemscope" value="itemscope"/>
    <referenceBlock name="head.components">
        <block class="Magento\Framework\View\Element\Js\Components" name="checkout_page_head_components" template="Magento_Catalog::js/components.phtml"/>
    </referenceBlock>
    <referenceBlock name="page.main.title">
        <arguments>
            <argument name="css_class" xsi:type="string">product</argument>
            <argument name="add_base_attribute" xsi:type="string">itemprop="name"</argument>
        </arguments>
    </referenceBlock>
    <referenceBlock name="root">
        <arguments>
            <argument name="add_attribute" xsi:type="string">itemscope itemtype="http://schema.org/Product"</argument>
        </arguments>
    </referenceBlock>
    <referenceContainer name="content">
        <container name="product.info.main" htmlTag="div" htmlClass="product-info-main" before="-">
            <container name="product.info.price" label="Product info auxiliary container" htmlTag="div" htmlClass="product-info-price" after="product.info.review">
                <container name="product.info.stock.sku" label="Product auxiliary info" htmlTag="div" htmlClass="product-info-stock-sku">
                    <container name="product.info.type" before="-"/>
                    <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.sku" template="product/view/attribute.phtml" after="product.info.type">
                        <arguments>
                            <argument name="at_call" xsi:type="string">getSku</argument>
                            <argument name="at_code" xsi:type="string">sku</argument>
                            <argument name="css_class" xsi:type="string">sku</argument>
                            <argument name="at_label" xsi:type="string">default</argument>
                            <argument name="add_attribute" xsi:type="string">itemprop="sku"</argument>
                        </arguments>
                    </block>
                </container>
                <block class="Magento\Catalog\Block\Product\View" name="product.info.review" template="product/view/review.phtml" after="product.info.stock.sku" />
                <block class="Magento\Catalog\Pricing\Render" name="product.price.final" after="product.info.sku">
                    <arguments>
                        <argument name="price_render" xsi:type="string">product.price.render.default</argument>
                        <argument name="price_type_code" xsi:type="string">final_price</argument>
                        <argument name="zone" xsi:type="string">item_view</argument>
                    </arguments>
                </block>
            </container>
            <block class="Magento\Catalog\Pricing\Render" name="product.price.tier" after="product.info.price">
                <arguments>
                    <argument name="price_render" xsi:type="string">product.price.render.default</argument>
                    <argument name="price_type_code" xsi:type="string">tier_price</argument>
                    <argument name="zone" xsi:type="string">item_view</argument>
                </arguments>
            </block>
            <container name="alert.urls" as="alert_urls" label="Alert Urls" after="product.price.tier"/>
            <block class="Magento\Catalog\Block\Product\View" name="product.info" template="product/view/form.phtml" after="alert.urls">
                <container name="product.info.form.content" as="product_info_form_content">
                    <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart" as="addtocart" template="product/view/addtocart.phtml"/>
                </container>
                <block class="Magento\Framework\View\Element\Template" name="product.info.form.options" as="options_container">
                    <block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper" as="product_options_wrapper" template="product/view/options/wrapper.phtml">
                        <block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="product/view/options.phtml">
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" as="default" template="product/view/options/type/default.phtml"/>
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" as="text" template="product/view/options/type/text.phtml"/>
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\File" as="file" template="product/view/options/type/file.phtml"/>
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" as="select" template="product/view/options/type/select.phtml"/>
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" as="date" template="product/view/options/type/date.phtml"/>
                        </block>
                        <block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/>
                    </block>
                    <block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="product/view/options/wrapper/bottom.phtml">
                        <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.additional" as="product.info.addtocart" template="product/view/addtocart.phtml"/>
                    </block>
                </block>
            </block>
            <container name="product.info.extrahint" as="extrahint" label="Product View Extra Hint">
                <container name="product.info.social" label="Product social links container" htmlTag="div" htmlClass="product-social-links" after="product.info.overview">
                    <referenceBlock name="product.info.addto" remove="true" />  
                    <block class="Magento\Catalog\Block\Product\View" name="product.info.mailto" template="product/view/mailto.phtml"/>
                </container>
            </container>
            <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.overview" template="product/view/attribute.phtml" group="detailed_info" after="product.info.extrahint">
                <arguments>
                    <argument name="at_call" xsi:type="string">getShortDescription</argument>
                    <argument name="at_code" xsi:type="string">short_description</argument>
                    <argument name="css_class" xsi:type="string">overview</argument>
                    <argument name="at_label" translate="true" xsi:type="string">none</argument>
                    <argument name="title" translate="true" xsi:type="string">Overview</argument>
                    <argument name="add_attribute" xsi:type="string">itemprop="description"</argument>
                </arguments>
            </block>
        </container>
        <container name="product.info.media" htmlTag="div" htmlClass="product media" after="product.info.main">
            <block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="product/view/gallery.phtml"/>
        </container>
        <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.details" template="product/view/details.phtml" after="product.info.media">
            <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" template="product/view/attribute.phtml" group="detailed_info">
                <arguments>
                    <argument name="at_call" xsi:type="string">getDescription</argument>
                    <argument name="at_code" xsi:type="string">description</argument>
                    <argument name="css_class" xsi:type="string">description</argument>
                    <argument name="at_label" xsi:type="string">none</argument>
                    <argument name="title" translate="true" xsi:type="string">Details</argument>
                </arguments>
            </block>
            <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="product/view/attributes.phtml" group="detailed_info">
                <arguments>
                    <argument translate="true" name="title" xsi:type="string">More Information</argument>
                </arguments>
            </block>
        </block>
    </referenceContainer>
    <referenceContainer name="content.aside" remove="true" />
    <referenceContainer name="customer.interceptor" remove="true" />
    <referenceBlock name="product.info.addtocart">
        <block class="Magento\Catalog\Block\ShortcutButtons\InCatalog" name="addtocart.shortcut.buttons"/>
    </referenceBlock>
    <referenceBlock name="product.info.addtocart.additional">
        <block class="Magento\Catalog\Block\ShortcutButtons\InCatalog" name="addtocart.shortcut.buttons.additional"/>
    </referenceBlock>
</body>

Edit: I have the cache disabled, and I cleared it anyways (the first thing I did), but still no results.

Edit 2: It is Magento 2.1.3 version

Best Answer

I've discovered what is causing the problem, it seems that when importing the project from magento 1.9 to 2.1, each individual product in each store was imported with a migration_design of '2 columns with left bar' causing the xml page layout being overriden by the cms product option.

If I edit a concrete product in a concrete store and change the migration design to 'no layout updates' then, this product have a 1 column layout in the store I changed it, if with this product I go to another store then it is displayed in 2 columns again.

The solution is edit the database, changing all the products in all the stores to 'no layout updates'.

Related Topic