How to Create an Inventory Source Programmatically

Coming back with another post about Magento inventory. In this post we will see together how you can create an inventory source programmatically.

You can simple create a custom inventory source creating an instance of the Magento\InventoryApi\Api\Data\SourceInterface populated with some required data and then using the Magento\InventoryApi\Api\SourceRepositoryInterface class to save it like below. Simple as that.

The full example as extension can be found here.

Feel free to share this post and ask your questions in the comments below.

Till next time!

DigitalOcean Referral Badge