6

module-sales/view/frontend/layout/sales_order_view.xml

has following code:

<update handle="sales_order_info_links"/>

Is there any pretty way to remove such updates?

p.s. I know about removing particular blocks existed in file sales_order_info_links.xml from another layout like this:

<referenceBlock name="sales.order.info.links" remove="true" />
1
  • Hi, did anyone found out answer for this?
    – Harshith S
    Commented Aug 28, 2019 at 4:43

1 Answer 1

0

There are 2 solutions to remove a layout handle from a layout file of a Magento module:

  1. Remove all content within the layout handle, including blocks, containers, the class attribute, changing the title, etc. by using referenceBlock, referenceContainer, etc. in your layout XML file.
  2. Remove the layout handle directly in the layout file using the Composer patches plugin.

In case the layout handle has many layout files (eg: the customer_account layout handle, which has several layout files) in several modules, solution 1 is difficult to implement and maintain. Therefore, solution 2 is recommended.

For instructions on how to create a custom composer patch, refer to the topic How to create a Magento 2 Patch?

To apply a custom composer patch, I recommend using the Vaimo Composer Patches plugin.
You also can use the Cweagans Composer Patches plugin

There is a Magento official document on how to apply a custom composer patch: https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/patches/apply.html


Regarding removing the sales_order_info_links layout handle from the sales_order_view.xml layout file of the Magento_Sales module. There is only one layout file, which is located in the Magento_Sales module with the following content:

<?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">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Html\Links" as="links" name="sales.order.info.links" before="-">
                ...
            </block>
        </referenceContainer>
    </body>
</page>

Therefore, you can implement solution 1, which removes the layout handle content by declaring the following in your sales_order_view.xml layout file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="sales.order.info.links" remove="true"/>
    </body>
</page>

Related topic: How to change <update handle="customer_account"/> in wishlist layout

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.