1

I'm trying to extend checkout page, I copied the

checkout_index_index.xml

in my layout folder (vendor/theme/Magento_Checkout/layout) I change some thing in the file, now in the payment method I can't find method I set on the admin page. If I remove my custom layout file, the method come's back and they work's fine.

This'is my custom xml file (I remove jsLayout part I didn't modify it):

<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
    <css src="css/checkout.css" media="screen,projection" />
</head>
<body>
    <referenceContainer name="page.messages" remove="true"/>
    <move element="logo" destination="top-header" before="header-links"/>
    <referenceContainer name="newsletternewsletter" remove="true"/>
    <referenceBlock name="page.main.title">
        <action method="setPageTitle">
            <argument translate="true" name="title" xsi:type="string">Checkout</argument>
        </action>
    </referenceBlock>
    <referenceContainer name="content">
        <container name="checkout-container" as="checkout-container" htmlTag="div" htmlClass="row no-margin">
            <container name="checkout-center" as="checkout-center" htmlTag="div" htmlClass="col s12 m10 l10 offset-m1 offset-l1">
                <container name="checkout-border" as="checkout-border" htmlTag="div" htmlClass="dashboard-container">

                    <block class="Magento\Checkout\Block\Onepage" name="checkout.root" template="Magento_Checkout::onepage.phtml" cacheable="false">
                        <arguments>
                            <argument name="jsLayout" xsi:type="array">
                                <!-- NO CHANGE HERE -->
                            </argument>
                        </arguments>
                    </block>

                </container>
            </container>
        </container>
    </referenceContainer>
</body>

1 Answers1

1

I saw many developers who did the same way. We shouldn't try to override the layouts by copying them to our module or theme. And then, we modify them.

In your case, we overridden "completely" the original layout. So, any changes will affect to the global layout node.

Rather than copy extensive page layout or page configuration code and then modify what you want to change, in the Magento system, you only need to create an extending layout file that contains the changes you want.

Magento 2 Layout

Khoa TruongDinh
  • 32,054
  • 11
  • 88
  • 155
  • You're right, if in my file I remove the block checkout.root and use the move attribute to put it where I want, the payment methods appear. But now I have the necessity to invert the order of some children inside the sidebar component, do you know any way to do it, without copy all the block? If I copy the block payment methods go way. – 3tech - Alessandro Staffolani Sep 19 '16 at 08:21
  • Read more here: http://magento.stackexchange.com/questions/133334/extension-attributes-to-add-product-attribute-to-the-order-summary-on-checkout/133732#133732 and http://magento.stackexchange.com/questions/109203/remove-a-ui-component-child-via-layout-xml/116415#116415 – Khoa TruongDinh Sep 19 '16 at 08:26
  • Could you write a simple example how to invert in sidebar component summary and cart-items children, I would like to set cart-items as first element and then summary element. I couldn't do it – 3tech - Alessandro Staffolani Sep 19 '16 at 09:04