I need to override the shippingmethodmagament.php file which is in the model file in the magento this path vendor\magento\module-quote\Model\ShippingMethodManagement.php

but the interfaces is applied in this file and i have try with the preference but its not properly work

I need to override this function inside the my custom module model please help me out to override this core function enter image description here

  • Try using this link it may help magento.stackexchange.com/questions/270381/…
    – Asssd
    Commented Oct 14, 2021 at 12:34
  • @Asssd i need to override the getShippingMethods function which is inside this model and that function is a private function
    – user92141
    Commented Oct 14, 2021 at 12:44
  • 1
    using prefrence will resolve it in above link there were multiple ways plugin and prefrence as you need it for private funciton use prefrence.
    – Asssd
    Commented Oct 14, 2021 at 12:44
  • preference is not worked on the interface class
    – user92141
    Commented Oct 14, 2021 at 12:46
  • What do you mean by "preference is not worked" ? Note that after modifying a constructor (what you are doing with a preference) you need to do a bin/magento setup:di:compile
    – Claims
    Commented Oct 14, 2021 at 12:58

1 Answer 1


This is some magento basics that you are missing there.

What you are probably looking for is called preference.

You need to write a preference in the di.xml of your custom module Just replace with the correct path


    <preference for="Magento\..\ShippingMethodManagement" type="Your_Module_Namespace\...\ShippingMethodManagement" />

Then you can write your own ShippingMethodManagement that extends the magento one.

  • I have updated my question please check
    – user92141
    Commented Oct 14, 2021 at 13:24

Your Answer

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