skip to Main Content

I want to remove some portion from di.xml of vendor module. Below example of some portion that to be removed.

<type name="MagentoBraintreeBlockGooglePayShortcutButton">
        <arguments>
            <argument name="data" xsi:type="array">
                <item name="template" xsi:type="string">Magento_Braintree::googlepay/shortcut.phtml</item>
                <item name="alias" xsi:type="string">braintree.googlepay.mini-cart</item>
                <item name="button_id" xsi:type="string">braintree-googlepay-mini-cart</item>
            </argument>
            <argument name="payment" xsi:type="object">BraintreeGooglePay</argument>
        </arguments>
    </type>

How can I remove the it using override of di.xml in custom module.

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for sharing the possible options.

    The solution that did work for me is to make the item inside argument tag to null. In my scenario, I do not want this item in dependency injection. That works for me.

    Below code added in custom module etc/frontend/di.xml

    <type name="MagentoBraintreeBlockGooglePayShortcutButton">
         <arguments>
            <argument name="data" xsi:type="array">
               <item name="template" xsi:type="null" />
               <item name="alias" xsi:type="null" />
               <item name="button_id" xsi:type="null" />
            </argument>
            <argument name="payment" xsi:type="object">BraintreeGooglePay</argument>
         </arguments>
    </type>
    

  2. Have you tried putting

    <type name="MagentoBraintreeBlockGooglePayShortcutButton">
        <arguments>
        </arguments>
    </type>
    

    Inside custom di.xml?
    Then run php bin/magento setup:upgrade, so that dependencies are updated.

    To remove the button completely, search for occurences of the block class and create own layout file(-s) in custom module (Vendor/Module/view/frontend/layout/{{THE_LAYOUT_NAME}}.xml) with following content:

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock name="{{GOOGLE_PAY_BUTTON_BLOCK_NAME}}" remove="true"/>
        </body>
    </page>
    

    EDIT: The button block name is defined within the layout files by the name attribute of <block> tag.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search