I am getting the product inventory source successfully below is my code.

 $sources = $this->getSourceItemsBySku->execute($sku);

 $array = [];

 foreach ($sources as  $index => $source) {

 $array[] = [
         'value' => $source->getSourceCode(),
         'label' => $source->getName()

Here you can see in an array I am getting value and label like this its showing be value but Label values in null $source->getName() so how I can get source name.

  • Not able to get your point, Can you try one more time:)
    – anonymous
    Feb 24 '20 at 7:41
  • i have checked code its just return source code not source value
    – testing
    Feb 24 '20 at 7:42
  • Source value means you want to retrieve all qty's available in different source ?
    – anonymous
    Feb 24 '20 at 7:44
  • no source name like wharehouse source name dropship soruce name
    – testing
    Feb 24 '20 at 7:51

You can get source lable/name by using Magento\InventoryApi\Api\SourceRepositoryInterface

You can try below, Its untested:)

$source = $this->sourceRepository->get('source_code');
$sourceName =  $source->getName();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.