0

I try to change the layout vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml in my own theme. I have overriden the layout file completly:

app\design\frontend\company\base\Magento_Catalog\layout\override\base\catalog_product_view.xml

I need to move the block options_container to a new container which I named configurator.

<container name="configurator.foo" htmlTag="div" htmlId="configurator_foo" after="product.info.main">
    <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="Magento_Catalog::product/view/options/wrapper.phtml">
            <block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="Magento_Catalog::product/view/options.phtml">
                <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" template="Magento_Catalog::product/view/options/type/default.phtml"/>
                <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" template="Magento_Catalog::product/view/options/type/text.phtml"/>
                <block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" template="Magento_Catalog::product/view/options/type/file.phtml"/>
                <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" template="Magento_Catalog::product/view/options/type/select.phtml"/>
                <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" template="Magento_Catalog::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="Magento_Catalog::product/view/options/wrapper/bottom.phtml">
            <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.additional" as="product.info.addtocart" template="Magento_Catalog::product/view/addtocart.phtml"/>
        </block>
    </block>
</container>

But the block is not showing, even after flushing all caches.

Full layout file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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="css/catalog/product/view.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"/>

        <!-- /** Remove the Product SKU information form the product detail page **/-->
            <referenceBlock name="sale.reorder.sidebar" remove="true"/>
            <referenceBlock name="skip_gallery_after" remove="true" />

        <!-- Add our custom breadcrumbs -->
            <referenceContainer name="content.top">
                <block class="Hausfux\Base\Block\Breadcrumbs" name="breadcrumbs" as="breadcrumbs" />
            </referenceContainer>

        <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="root">
                <arguments>
                    <argument name="add_attribute" xsi:type="string">itemscope itemtype="http://schema.org/Product"</argument>
                </arguments>
            </referenceBlock>

        <referenceContainer name="content">

            <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>

            <!-- Create mobile container, used to move elements into it on mobile view for reordering positions -->
                <container name="mobile_container_top" htmlTag="div" htmlId="mobile_container_top" before="-">
                    <block class="Magento\Framework\View\Element\Template" name="mobile_container_template"
                           template="Magento_Catalog::product/view/mobile.phtml"
                    />
                </container>

            <!-- Produkt Info -->
                <container name="product.info.main" htmlTag="div" htmlClass="product-info-main" before="-">

                    <!-- Bewertungsanzeige -->
                        <block class="Magento\Catalog\Block\Product\View" name="product.info.review"
                               template="Magento_Catalog::product/view/review.phtml"
                        />

                    <!-- Kurzbeschreibung -->
                        <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.overview"
                               template="Magento_Catalog::product/view/attribute.phtml"
                        >
                            <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" 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>

                    <!-- Links zum springen zu Produktdetails, Einbausituationen, Montageanleitungen -->
                        <block class="Magento\Framework\View\Element\Template" name="links"
                               template="Magento_Catalog::product/view/links.phtml"
                               after="product.info.overview"
                        />

                    <!-- Preis -->
                        <container name="product.info.price" label="Product info auxiliary container" htmlTag="div" htmlClass="product-info-price">
                            <container name="product.info.stock.sku" label="Product auxiliary info" htmlTag="div" htmlClass="product-info-stock-sku">
                                <container name="product.info.type" before="-"/>
                            </container>

                            <block class="Magento\Catalog\Pricing\Render" name="product.price.final">
                                <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>

                    <!-- Gruppenpreis -->
                        <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="Magento_Catalog::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="Magento_Catalog::product/view/addtocart.phtml"
                                />
                            </container>
                        </block>

                    <!-- Vergleichsliste -->
                        <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">
                                <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto"
                                       template="Magento_Catalog::product/view/addto.phtml"
                                >
                                    <block class="Magento\Catalog\Block\Product\View\AddTo\Compare" name="view.addto.compare"
                                           after="view.addto.wishlist"
                                           template="Magento_Catalog::product/view/addto/compare.phtml"
                                    >
                                        <arguments>
                                            <argument name="addToCompareViewModel" xsi:type="object">Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability</argument>
                                        </arguments>
                                    </block>
                                </block>
                                <block class="Magento\Catalog\Block\Product\View" name="product.info.mailto" 
                                       template="Magento_Catalog::product/view/mailto.phtml"
                                />
                            </container>
                        </container>
                </container>

            <!-- Media -->
                <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="Magento_Catalog::product/view/gallery.phtml">
                        <arguments>
                            <argument name="gallery_options" xsi:type="object">Magento\Catalog\Block\Product\View\GalleryOptions</argument>
                            <argument name="imageHelper" xsi:type="object">Magento\Catalog\Helper\Image</argument>
                        </arguments>
                    </block>
                </container>

        <!-- Konfigurator -->
            <container name="configurator.foo" htmlTag="div" htmlId="configurator_foo" after="product.info.media">
                <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="Magento_Catalog::product/view/options/wrapper.phtml"
                    >
                        <block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" 
                               template="Magento_Catalog::product/view/options.phtml"
                        >
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" 
                                   template="Magento_Catalog::product/view/options/type/default.phtml"
                            />
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" 
                                   template="Magento_Catalog::product/view/options/type/text.phtml"
                            />
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" 
                                   template="Magento_Catalog::product/view/options/type/file.phtml"
                            />
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" 
                                   template="Magento_Catalog::product/view/options/type/select.phtml"
                            />
                            <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" 
                                   template="Magento_Catalog::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="Magento_Catalog::product/view/options/wrapper/bottom.phtml"
                    >
                        <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.additional" as="product.info.addtocart" 
                               template="Magento_Catalog::product/view/addtocart.phtml"
                        />
                    </block>
                </block>
            </container>


        <!-- Details Block -->
            <block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details"
                   template="Magento_Catalog::product/view/details.phtml"
                   after="configurator.foo"
            >

                <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description"
                       template="Magento_Catalog::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>
                        <argument name="sort_order" xsi:type="string">10</argument>
                    </arguments>
                </block>

                <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional"
                       template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
                    <arguments>
                        <argument translate="true" name="title" xsi:type="string">More Information</argument>
                        <argument name="sort_order" xsi:type="string">20</argument>
                    </arguments>
                </block>
            </block>

        <!-- Reviews -->
        <!-- Make review standalone -->
            <container name="product_review_wrapper" htmlTag="div" htmlId="product_reviews_wrapper" after="-">
                <block class="Magento\Framework\View\Element\Template" name="product_reviews_wrapper_block"
                       template="Magento_Review::product_review_wrapper.phtml"
                />

                <container name="product_review_content_wrapper" htmlTag="div" htmlId="product_review_content_wrapper" after="-"/>
            </container>


        <!-- Cookies -->
            <block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" 
                   template="Magento_Cookie::require_cookie.phtml"
            >
                <arguments>
                    <argument name="triggers" xsi:type="array">
                        <item name="compareProductLink" xsi:type="string">.action.tocompare</item>
                    </argument>
                </arguments>
            </block>
            
        <!-- Product View Counter -->
            <block  class="Magento\Catalog\Block\Ui\ProductViewCounter" name="product_viewed_counter"
                    template="Magento_Catalog::product/view/counter.phtml"
            />

        </referenceContainer>


    <!-- Related, Upsell -->
        <referenceContainer name="content.aside">

            <!-- Related Products Slider -->
                <block class="Magento\Catalog\Block\Product\ProductList\Related" name="catalog.product.related"
                       template="Magento_Catalog::product/list/items.phtml"
                >
                    <arguments>
                        <argument name="type" xsi:type="string">related</argument>
                    </arguments>
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="related.product.addto" as="addto">
                        <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare" name="related.product.addto.compare" as="compare"
                               template="Magento_Catalog::product/list/addto/compare.phtml"
                        />
                    </block>
                </block>

            <!-- Upsell Products Slider -->
                <block class="Magento\Catalog\Block\Product\ProductList\Upsell"
                       name="product.info.upsell" template="Magento_Catalog::product/list/items.phtml">
                    <arguments>
                        <argument name="type" xsi:type="string">upsell</argument>
                    </arguments>
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="upsell.product.addto" as="addto">
                        <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare" name="upsell.product.addto.compare" as="compare"
                               template="Magento_Catalog::product/list/addto/compare.phtml"
                        />
                    </block>
                </block>

            <!-- Additional (?) -->
                <block class="Magento\Catalog\Block\Product\View\Additional" name="product.info.additional" as="product_additional_data"/>
        </referenceContainer>


        <!-- Unknown -->
            <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>
</page>
  • the layout path seems to be wrong. Try with app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_product_view.xml – Mattia Kozianowski Apr 2 at 11:46
  • No it is correct. I am overriding the layout. The layout file works, but the new container is not showing. – Black Apr 2 at 11:52
  • What exactly is showing? – Ben Crook Apr 2 at 11:54
  • @BenCrook, everything as usual, but the options are not showing anymore since I moved them to the new container which does not render. – Black Apr 2 at 11:55
0

I figured it out. I had to move the whole block:

<!-- Konfigurator -->
    <container name="configurator.foo" htmlTag="div" htmlId="configurator_foo" after="product.info.media">
        <block class="Magento\Catalog\Block\Product\View" name="product.info" template="Magento_Catalog::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="Magento_Catalog::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="Magento_Catalog::product/view/options/wrapper.phtml">
                    <block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="Magento_Catalog::product/view/options.phtml">
                        <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" template="Magento_Catalog::product/view/options/type/default.phtml"/>
                        <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" template="Magento_Catalog::product/view/options/type/text.phtml"/>
                        <block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" template="Magento_Catalog::product/view/options/type/file.phtml"/>
                        <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" template="Magento_Catalog::product/view/options/type/select.phtml"/>
                        <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" template="Magento_Catalog::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="Magento_Catalog::product/view/options/wrapper/bottom.phtml">
                    <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.additional" as="product.info.addtocart" template="Magento_Catalog::product/view/addtocart.phtml"/>
                </block>
            </block>
        </block>
    </container>

Because the block options_container only renders in the block product.info

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.