Magento2 – Multi-Source Inventory – Useful Functions

Get Source Item by SKU

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\InventoryApi\Api\SourceItemRepositoryInterface;

/*@var Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteria = $searchCriteriaBuilder
            ->addFilter(SourceItemInterface::SKU, $sku)
            ->create();
/*@var SourceItemRepositoryInterface $sourceItemRepository */

$sourceItemsResult = $sourceItemRepository->getList($searchCriteria);

Leave a Reply

Your email address will not be published. Required fields are marked *