Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StockResolver.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 use Magento\InventorySalesApi\Api\Data\SalesChannelInterfaceFactory;
15 
20 {
24  private $getStockBySalesChannel;
25 
29  private $salesChannelInterfaceFactory;
30 
35  public function __construct(
36  GetStockBySalesChannelInterface $getStockBySalesChannel,
37  SalesChannelInterfaceFactory $salesChannelInterfaceFactory
38  ) {
39  $this->getStockBySalesChannel = $getStockBySalesChannel;
40  $this->salesChannelInterfaceFactory = $salesChannelInterfaceFactory;
41  }
42 
46  public function execute(string $type, string $code): StockInterface
47  {
48  $salesChannel = $this->salesChannelInterfaceFactory->create([
49  'data' => [
52  ]
53  ]);
54  return $this->getStockBySalesChannel->execute($salesChannel);
55  }
56 }
__construct(GetStockBySalesChannelInterface $getStockBySalesChannel, SalesChannelInterfaceFactory $salesChannelInterfaceFactory)
execute(string $type, string $code)
$type
Definition: item.phtml:13
$code
Definition: info.phtml:12