0

I have a third party module that has this class

app/code/Vendor/ModuleName/CustomerData/Popup.php

and that class is defined in the frontend/di.xml file like this

    <type name="Magento\Customer\CustomerData\SectionPoolInterface">
        <arguments>
            <argument name="sectionSourceMap" xsi:type="array">
                <item name="popup" xsi:type="string">Vendor\ModuleName\CustomerData\Popup</item>
            </argument>
        </arguments>
    </type>

I am trying to override the class "app/code/Vendor/ModuleName/CustomerData/Popup.php" as it has some protected methods. I tried to use preferences in myVendor etc/di.xml file like

<preference for="Vendor\ModuleName\CustomerData\Popup" type="MyVendor\VendorModuleNameExtend\Rewrite\Vendor\ModuleName\CustomerData\Popup"/>

But this is not working and on the storefront, I get errors on customerData.js.

Is there a way that I can override that third-party module di.xml or class and replace my own with argument->item of my own class?

4
  • for argument or add new dependency you can use virtual type and create new sub class Commented Mar 31, 2022 at 13:33
  • @Vikaskalal tnx, can you please add a document or a sample tutorial? I couldn't fine something useful.
    – Korbin
    Commented Mar 31, 2022 at 13:37
  • 1
    Yoc can follow this tutorial to create virtual type may your requirement fulfilled. asolutions.co.in/virtual-type-in-magento-2 Commented Mar 31, 2022 at 13:40
  • tnx, I will check it.
    – Korbin
    Commented Mar 31, 2022 at 14:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.