Is there a way to override ViewModel Function

I Have a installed a Module in vendor but I want to override Function of ViewModel

1 Answer 1


You still be able to using preference or plugin for the ViewModel Class.

For example Magento\Customer\ViewModel\Address

<preference for="Magento\Customer\ViewModel\Address" type="Foo\Bar\ViewModel\Address"/>

<type name="Magento\Customer\ViewModel\Address">
        <plugin sortOrder="10" name="Foo_Bar::do_stuff" type="Foo\Bar\Plugin\ViewModel\AddressPlugin"/>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.