13

I want to undo the removal of a block.

the block is removed in vendor/magento/theme-frontend-blank/Magento_Checkout/layout/checkout_index_index.xml

<referenceBlock name="minicart" remove="true"/>
<referenceContainer name="header.panel" remove="true"/>
<referenceBlock name="top.search" remove="true"/>
<referenceBlock name="catalog.compare.link" remove="true"/>
<referenceBlock name="catalog.topnav" remove="true"/>
<referenceContainer name="footer-container" remove="true"/>

According to the documentation, one can canel the removal with remove=false.

So I created a file in my theme in Magento_Checkout/layout/checkout_index_index.xml

<referenceBlock name="minicart" remove="false"/>
<referenceContainer name="header.panel" remove="false"/>
<referenceBlock name="top.search" remove="false"/>
<referenceBlock name="catalog.compare.link" remove="false"/>
<referenceBlock name="catalog.topnav" remove="false"/>
<referenceContainer name="footer-container" remove="false"/>

But this does not work. According to this github issue, it's not a bug

EDIT:

Here's also a related forum post

2
  • 3
    on first sight this sounds like a bug to me. The issue on github got closed I think because it sounds like a question. Maybe if you could provide a complete example in the issue (or maybe also a new issue) to reproduce the behaviour it could be reopened. Mar 16, 2016 at 18:00
  • You have to override theme xml file. Jul 25, 2016 at 7:31

4 Answers 4

4

No need to override anything, after you add all of these remove to false

<referenceBlock name="minicart" remove="false"/>
<referenceContainer name="header.panel" remove="false"/>
<referenceBlock name="top.search" remove="false"/>
<referenceBlock name="catalog.compare.link" remove="false"/>
<referenceBlock name="catalog.topnav" remove="false"/>
<referenceContainer name="footer-container" remove="false"/>

You need to recreate their layout xml again. an example would be to search for top.search block and see how it was created and then copy the same block xml in your layout xml file.

An example would be like this

<referenceBlock name="product.info.description" remove="false" />

and right after

<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.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>
                            </arguments>
                        </block>
1
  • 2
    you are correct! when I asked this question (2 years ago) this was a bug and not working. Meanwhile it's fixed. Sep 3, 2018 at 7:20
3

I also faced the same issue and it was solved by overriding the default folder.

By default it is disabled in luma/blank theme. you just need to create basic structure on your theme folder and re-add the blocks you want

yourthemename\Magento_Checkout\layout\override\theme\Magento\blank

just copy checkout_index_index.xml here and in this file paste the below code

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
  <!-- <referenceBlock name="minicart" remove="true"/>-->
   <!--<referenceContainer name="header.panel" remove="true"/>-->
    <referenceBlock name="top.search" remove="true"/>
    <referenceBlock name="catalog.compare.link" remove="true"/>
    <referenceBlock name="catalog.topnav" remove="true"/>
   <!--<referenceContainer name="footer-container" remove="true"/>-->
</body>

You can block remove true/false like this.

3

This looks like it is a bug, and has now been fixed in Development.

See the discussion on github as issue #1931.

The patch itself can be found as: 9bd170d.

An alternative suggestion, if you have control over parent and child, was to use display instead of remove

<!-- parent_layout_handle.xml -->
+ <referenceContainer name="root" display="false"/>
- <referenceContainer name="root" remove="true"/>

<!-- child_layout_handle.xml -->
+ <referenceContainer name="root" display="true"/>
- <referenceContainer name="root" remove="false"/>
1

I had same issue and I also want to show header and footer in checkout page so please check this link you will find this useful.

add header and footer in checkout

0

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.