0

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.

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

1 Answer 1

0

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 and acknowledge you have read our privacy policy.

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