Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-sales
Model
GetStockBySalesChannel.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventorySales\Model
;
9
10
use
Magento\Framework\Exception\NoSuchEntityException
;
11
use
Magento\InventoryApi\Api\Data\StockInterface
;
12
use
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
;
13
use
Magento\InventorySalesApi\Api\GetStockBySalesChannelInterface
;
14
use
Magento\InventoryApi\Api\StockRepositoryInterface
;
15
use
Magento\InventorySales\Model\ResourceModel\StockIdResolver
;
16
20
class
GetStockBySalesChannel
implements
GetStockBySalesChannelInterface
21
{
25
private
$stockRepository;
26
30
private
$stockIdResolver;
31
36
public
function
__construct
(
37
StockRepositoryInterface
$stockRepositoryInterface,
38
StockIdResolver
$stockIdResolver
39
) {
40
$this->stockRepository = $stockRepositoryInterface;
41
$this->stockIdResolver = $stockIdResolver;
42
}
43
47
public
function
execute
(
SalesChannelInterface
$salesChannel):
StockInterface
48
{
49
$stockId = $this->stockIdResolver->resolve(
50
$salesChannel->
getType
(),
51
$salesChannel->
getCode
()
52
);
53
54
if
(
null
=== $stockId) {
55
throw
new
NoSuchEntityException
(
__
(
'No linked stock found'
));
56
}
57
return
$this->stockRepository->get($stockId);
58
}
59
}
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\getType
getType()
Magento\InventorySales\Model\ResourceModel\StockIdResolver
Definition:
StockIdResolver.php:17
Magento\InventoryApi\Api\StockRepositoryInterface
Definition:
StockRepositoryInterface.php:26
Magento\InventoryApi\Api\Data\StockInterface
Definition:
StockInterface.php:17
__
__()
Definition:
__.php:13
Magento\InventorySalesApi\Api\GetStockBySalesChannelInterface
Definition:
GetStockBySalesChannelInterface.php:15
Magento\InventorySales\Model\GetStockBySalesChannel\__construct
__construct(StockRepositoryInterface $stockRepositoryInterface, StockIdResolver $stockIdResolver)
Definition:
GetStockBySalesChannel.php:36
Magento\InventorySales\Model\GetStockBySalesChannel\execute
execute(SalesChannelInterface $salesChannel)
Definition:
GetStockBySalesChannel.php:47
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
Definition:
SalesChannelInterface.php:17
Magento\InventorySales\Model
Definition:
CheckItemsQuantity.php:8
Magento\InventorySales\Model\GetStockBySalesChannel
Definition:
GetStockBySalesChannel.php:20
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\getCode
getCode()