Get source by source code Multi Source Inventory(MSI) Magento 2

We can use Repository \Magento\InventoryApi\Api\SourceRepositoryInterface to get the source by code Here is the sample model class <?php namespace Mageprince\Testing\Model; class SourceModel { private $sourceRepository; public function __construct( ... \Magento\InventoryApi\Api\SourceRepositoryInterface $sourceRepository ... ) { $this->sourceRepository = $sourceRepository; } public function getSourcesByCode($sourceCode) { return $this->sourceRepository->get($storeCode); } } Now you can use getSourcesByCode() function to get the…

Continue Reading

Get source by name Multi Source Inventory(MSI) Magento 2

You can get the source by using the repository \Magento\InventoryApi\Api\SourceRepositoryInterface and filter source name by using \Magento\Framework\Api\SearchCriteriaBuilder Magento has default source with name “Default Source”. You can't delete this source. You can get the source by its name, code, description, latitude, longitude and postcode Here is the example of retrieving the source data <?php namespace…

Continue Reading

Get source item data by source code and SKU Multi Source Inventory(MSI) Magento 2

We can use \Magento\InventoryApi\Api\SourceItemRepositoryInterface class with \Magento\Framework\Api\SearchCriteriaBuilder to get source item data by source code and product SKU. Here are the sample model class <?php namespace Mageprince\Testing\Model; class SourceItemModel { private $searchCriteriaBuilder; private $sourceItemRepository; public function __construct( ... \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\InventoryApi\Api\SourceItemRepositoryInterface $sourceItemRepository ... ) { $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->sourceRepository = $sourceRepository; } public function getSourcesItems($souceCode,…

Continue Reading

Get source item data by source code Multi Source Inventory(MSI) in Magento 2

We can use \Magento\InventoryApi\Api\SourceItemRepositoryInterface class to get source items Here are the sample model class to get the sources item by source code <?php namespace Mageprince\Testing\Model; class SourceItemModel { private $searchCriteriaBuilder; private $sourceItemRepository; public function __construct( ... \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\InventoryApi\Api\SourceItemRepositoryInterface $sourceItemRepository ... ) { $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->sourceRepository = $sourceRepository; } public function getSourcesItems($souceCode) {…

Continue Reading

Get source item data by SKU Multi Source Inventory(MSI) Magento 2

You can get sources item by product SKU by class \Magento\InventoryApi\Api\GetSourceItemsBySkuInterface You can get source_item_id, source_code, sku, quantity and status I have created a sample model to show you how can you get sources item by SKU <?php namespace Mageprince\Testing\Model; class SourceListModel { private $sourceItemsBySku; public function __construct( ... \Magento\InventoryApi\Api\GetSourceItemsBySkuInterface $sourceItemsBySku, ... ) { $this->sourceItemsBySku…

Continue Reading

How to get list of sources Multi Source Inventory (MSI) programmatically in Magento 2

With the Magento version, 2.3 Multi-source inventory (MSI) Was Introduced. With the default Magento MSI, you can create multiple sources which contain stores data. like source_code, name, warehouse_id, latitude, longitude, etc. You can get all sources which are added by Magento admin by class Magento\InventoryApi\Api\SourceRepositoryInterface Here is the source collection factory class: Magento\Inventory\Model\ResourceModel\Source\CollectionFactory Here are…

Continue Reading
Close Menu