PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How to override di.xml of core module in custom module Magento 2

 August 23, 2022     magento2, php-7.3     No comments   

Issue

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

<type name="Magento\Braintree\Block\GooglePay\Shortcut\Button">
        <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.


Solution

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="Magento\Braintree\Block\GooglePay\Shortcut\Button">
     <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>


Answered By - Rahul Hedaoo
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing