My use case is, that I copied parts of the Magento checkout to the bundle's product's page. i.e. I copied parts from app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml to app/design/frontend/Example/default/Magento_Bundle/layout/override/base/catalog_product_view_type_bundle.xml. (which is used in catalog_product_view action)

But I also had to search in other checkout_cart_index.xml files for parts to copy. Especially the payment method renderers, as found for example in app/code/Magento/Paypal/view/frontend/layout/checkout_index_index.xml.

Is there a smarter way than copying this manually, for example by a layout <move> statement? But I guess I can retrieve layout information from other actions? Is there a trick to do so?

  • I assume this is more than just calling another layout handle, but actually being selective in which parts you want to call right? Oct 24, 2015 at 18:58

2 Answers 2


<update> instruction is there to "copy" content of layout handles.

  • Thanks.but can I also select just some nodes or do I have to delete and move around the stuff I don't want?
    – Alex
    Oct 25, 2015 at 18:42
  • You can not select nodes.
    – Anton Kril
    Oct 28, 2015 at 16:44

I ended up in doing the following:

  1. use <update handle="checkout_index_index"/> as suggested by Anton Kril to copy the full layout file (checkout_index_index to my layout)
  2. Set <referenceContainer name="page.messages" remove="false"/> because there is a <referenceContainer name="page.messages" remove="true"/> in checkout_index_index which I do not want. The remaining part in checkout_index_index is just the checkout.root block.
  3. I can now use a <move> to put the checkout block to the place where I need it
  4. Use removeComponent=true to "clean up" the checkout. As in Remove a UI component child via Layout XML
  5. I needed to change the Onepage block class -> did this via a DI rewrite

Alternative Approach

My first approach was to manipulate the XML. This is possible by hooking to \Magento\Framework\View\Layout::generateXml and use DOMDocument to rewrite the generated XML.

As I found out that it is also possible with a combination of standard Magento 2 methods, I dumped this approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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