0

I am trying to override the vendor/magento/module-inventory-in-store-pickup/Model/GetPickupLocations.php file

I have copied it to app/design/frontend/Magento/child_theme/Magento_InventoryInStorePickup/Model/GetPickupLocations.php

but it doesn't seem to work, have I copied it to the correct location?

1 Answer 1

0

If you want to override model (or extend) you should to create your own module in app/code/VendorName/InventoryInStorePickup where you define plugin or preference in etc/di.xml file.

Remember that using preferences and overwriting the entire model is not the best solution.

Why you want to override whole model? What you want to do? Maybe all you need to do is create a plugin for an interesting method from GetPickupLocations model?

First, take a look how to create basic module: https://www.cloudways.com/blog/create-module-in-magento-2/

Next, read how to create plugin for interesting method https://developer.adobe.com/commerce/php/development/components/plugins/

New contributor
GieDe is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • I have amended the original Magento GetPickupLocations.php file, rather than uploading it back to vendor/magento/module-inventory-in-store-pickup/Model/ I wanted to copy it to my theme instead
    – miller75
    Sep 22 at 20:56
  • You shouldn't edit the original files as you know. I would like to help you, but you didn't answer my questions. Read my answer and think about what you should do (plugin or preference).
    – GieDe
    Sep 22 at 21:04
  • I have had a quick look at the interception method, I will probably go down this route but will have a proper look in the morning. Thanks for your help
    – miller75
    Sep 22 at 22:15

Your Answer

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

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