11

I am creating Magento 2 theme using the blank theme as the base. Now the problem is Magento 2 blank theme removing the top header, search bar, mini cart on http://www.yourdomain/checkout page

vendor\magento\theme-frontend-blank\Magento_Checkout\layoutcheckout_cart_index.xml

they have removed using

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; 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>
</page>

If I override the same theme with here it is not working. What I want is not remove those elements so I have to override XML file here

app\design\frontend\NAMESPACE\themename\Magento_Checkout\layout\checkout_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <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"/>

    </body>
</page>

I have written remove="false" to not to remove those elements from checkout.

But it is still remove theme an idea ?

I have checked after clear cache and re-indexing but not working

1 Answer 1

15

To override a layout XML file (rather than extend) you need to add it to a slightly different directory, more info can be found in the official docs

<theme_dir>
  |__/<Namespace_Module>
    |__/layout
      |__/override
         |__/theme
            |__/<Parent_Vendor>
               |__/<parent_theme>
                  |--<layout1>.xml
                  |--<layout2>.xml

So for your case where you need to override Magento\Blank it would be:

app\design\frontend\NAMESPACE\themename\Magento_Checkout\layout\override\theme\Magento\blank\checkout_index_index.xml

If overriding the theme doesn't work, make sure you don't need to override the layout coming from the module itself rather than the theme's XML. To do this read the 'Override base layouts' section in the docs linked above.

11
  • already marked as correct ans... Mar 23, 2016 at 12:44
  • What to do if I receive the following message: Overriding view file ... does not match to any of the files. ? Aug 5, 2016 at 10:59
  • It was set like this on version 2.06, but after upgrade to 2.1 I got this message. Moving file to 'layout' folder worked. Aug 5, 2016 at 11:13
  • 1
    @VasiliiBurlacu - I haven't had chance to try with 2.1, but according to the docs the method of overriding XML files is the same on 2.1 - devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/…
    – Ben Crook
    Aug 5, 2016 at 13:07
  • @Ben-Space48 I didn't say that overriding method changed, I wrote about the error I was given. My checkout_index_index.ml was in right there where your post says, but after upgrading to 2.1 and running setup:upgrade & setup:static-content:deploy Magento FE was printing the exception with given message. Aug 5, 2016 at 17:26

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.