You can use GetSourceItemBySku
to get all SourceItem
from product's sku. Then you can foreach the array and getSourceCode()
from SourceItem.
Please check this path: /vendor/magento/module-inventory/Model/SourceItem/Command/GetSourceItemsBySku.php
After defined and declared GetSourceItemsBySkuInterface
, just use it in your function.
$availableSourcesForProduct = $this->sourceItemsBySku->execute($sku);
Refer this file to know how to use it, /vendor/magento/module-inventory-grouped-product-admin-ui/Plugin/Catalog/Model/Product/Link/ProcessSourceItemsAfterSaveAssociatedLinks.php
. Check function processSourceItemsForSku
Good luck!!!