I have the following vendor module file:


Which is giving me some issues on my current Magento 2.3 instance, so I wanted to overwrite a function within this file. I checked the registration of that vendor module and it is:


What I did was:



On that Button.php I made the changes I needed. But this didn't work, so I made an etc folder and created a di.xml file with the following code:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magenest\InstagramShop\Block\Adminhtml\System\Config\Form" type="Magenest\InstagramShop\Block\Adminhtml\System\Config\Form"/>

Then I ran:

php bin/magento setup:upgrade && php bin/magento setup:di:compile && php bin/magento setup:static-content:deploy -f && php bin/magento cache:flush && chmod -R 777 var/ pub/static/ generated/ && php bin/magento cache:flush

But when I go to the admin panel and into the module that is giving me issues, the same error persists. The error still points to: /var/www/html/vendor/magenest/module-instagram-shop/Block/Adminhtml/System/Config/Form/Button.php on line 77

SO my question is, how can I overwrite that specific vendor file? Do I need a registration.php even though I DON'T want a custom module just to extend a vendor one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.