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

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

How to use multiple AND and OR conditions in searchCriteria filter in Magento 2?

In this article, I will show you how you can use multiple OR and AND operation in searchCriteria filter. When we are working with API and working with getList collection using searchCriteria, we sometimes need to build a custom query to get the collection. There are two main part of searchCrieria FilterFilter Group 1. Filter…

Continue Reading How to use multiple AND and OR conditions in searchCriteria filter in Magento 2?

How to use Search Criteria for the custom collection in Magento 2?

In this article, I will show you, how you can use Search Criteria in the custom collection. Search Criteria is an implementation of the SearchCriteriaInterface class that allows you to build custom requests with different conditions. You can read more at devdoc for Search Criteria Searching with Repositories 1. Here we use getList() method to get custom…

Continue Reading How to use Search Criteria for the custom collection in Magento 2?