How to Get Product Salable Quantity By Stock Id in Magento 2

Hello Magento folks, welcome back to my new article about getting product salable quantity by stock id. There is lots of articles and stack exchange answer to get salable qty by SKU but here in this article, I will give you sample code to get salable qty by stock. We can use an interface Magento\InventorySalesApi\Api\GetProductSalableQtyInterface…

Continue Reading How to Get Product Salable Quantity By Stock Id in Magento 2

How to show source in shipment grid Magento 2 MSI

Hello Guys! Welcome back to another topic. Today I will show you how we can show supply source in shipment grid. With default Magento we can see Shipment number, Ship Date, Order, Order Date, Total Quantity etc. in shipment grid. To show the source of shipment we need to join inventory_shipment_source table to shipment grid…

Continue Reading How to show source in shipment grid Magento 2 MSI

How to Create Shipment Programmatically with Source Selection MSI Magento 2

Hello Guys! Welcome back to my blog. There are many tutorials and stack Exchange answers available for programmatically create a shipment in Magento 2. But today in this article I'll talk about how we can programmatically create a shipment in multi stock inventory MSI in Magento 2. For MSI we need to assign a source…

Continue Reading How to Create Shipment Programmatically with Source Selection MSI Magento 2

How to get source by shipment Id in Magento 2 MSI

Hello guys! In this article, I will show you how we can get the assigned source of the shipment by shipment id. There are two way to get source by shipment id Method 1: We can use the Magento Inventory shipping class Magento\InventoryShipping\Model\ResourceModel\ShipmentSource\GetSourceCodeByShipmentId Method 2: Or by using Magento shipment repository Magento\Sales\Api\ShipmentRepositoryInterface Here is the…

Continue Reading How to get source by shipment Id in Magento 2 MSI

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 source code Multi Source Inventory(MSI) Magento 2

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 by name Multi Source Inventory(MSI) Magento 2

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 and SKU Multi Source Inventory(MSI) Magento 2

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 source code Multi Source Inventory(MSI) in Magento 2

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 Get source item data by SKU Multi Source Inventory(MSI) Magento 2

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 How to get list of sources Multi Source Inventory (MSI) programmatically in Magento 2