Skip to content

How to remove parent theme handle from child theme programmatically?

Parent theme (theme design directory path)

app/design/frontend/Jigar/basetheme/Magento_Customer/layout/customer_account_create.xml

Here is the sample code :

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customheader" /> 
    <body>
        .....
    </body>
</page>

Now, While inside the child theme, I want to do some customization which I have done in the same file.

app/design/frontend/Jigar/childtheme/Magento_Customer/layout/customer_account_create.xml

But it is also taking the content from the parent theme (taking blocks and containers from update handle “customheader),

I have cross-verified by checking the body tag having “customheader” class for in child theme.

I want to remove the handle “customheader” from my child theme programmatically.

I have tried $layout->getUpdate()->removeHandle('customheader') using observer of layout_load_before but it is not working.

Note: I want to remove the handle programmatically only, I don’t want to remove each blocks and container manually.