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-catalog
Plugin
InventorySalesApi
StockResolver
AdaptStockResolverToAdminWebsitePlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver
;
9
10
use
Magento\InventoryApi\Api\Data\StockInterface
;
11
use
Magento\InventoryCatalogApi\Api\DefaultStockProviderInterface
;
12
use
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
;
13
use
Magento\InventorySalesApi\Api\GetStockBySalesChannelInterface
;
14
use
Magento\Store\Api\Data\WebsiteInterface
;
15
use
Magento\InventorySalesApi\Api\StockResolverInterface
;
16
use
Magento\InventoryApi\Api\StockRepositoryInterface
;
17
21
class
AdaptStockResolverToAdminWebsitePlugin
22
{
26
private
$stockRepository;
27
31
private
$defaultStockProviderInterface;
32
37
public
function
__construct
(
38
DefaultStockProviderInterface
$defaultStockProviderInterface,
39
StockRepositoryInterface
$stockRepositoryInterface
40
) {
41
$this->defaultStockProviderInterface = $defaultStockProviderInterface;
42
$this->stockRepository = $stockRepositoryInterface;
43
}
44
52
public
function
aroundExecute
(
53
GetStockBySalesChannelInterface
$getStockBySalesChannel,
54
callable $proceed,
55
SalesChannelInterface
$salesChannel
56
):
StockInterface
{
57
if
(
SalesChannelInterface::TYPE_WEBSITE
=== $salesChannel->
getType
()
58
&&
WebsiteInterface::ADMIN_CODE
=== $salesChannel->
getCode
()) {
59
return
$this->stockRepository->get($this->defaultStockProviderInterface->getId());
60
}
61
return
$proceed($salesChannel);
62
}
63
}
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\getType
getType()
Magento\InventorySalesApi\Api\StockResolverInterface
Definition:
StockResolverInterface.php:15
Magento\Store\Api\Data\WebsiteInterface\ADMIN_CODE
const ADMIN_CODE
Definition:
WebsiteInterface.php:19
Magento\InventoryApi\Api\StockRepositoryInterface
Definition:
StockRepositoryInterface.php:26
Magento\InventoryApi\Api\Data\StockInterface
Definition:
StockInterface.php:17
Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver\AdaptStockResolverToAdminWebsitePlugin\__construct
__construct(DefaultStockProviderInterface $defaultStockProviderInterface, StockRepositoryInterface $stockRepositoryInterface)
Definition:
AdaptStockResolverToAdminWebsitePlugin.php:37
Magento\InventorySalesApi\Api\GetStockBySalesChannelInterface
Definition:
GetStockBySalesChannelInterface.php:15
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\TYPE_WEBSITE
const TYPE_WEBSITE
Definition:
SalesChannelInterface.php:29
Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver
Definition:
AdaptStockResolverToAdminWebsitePlugin.php:8
Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver\AdaptStockResolverToAdminWebsitePlugin
Definition:
AdaptStockResolverToAdminWebsitePlugin.php:21
Magento\InventoryCatalog\Plugin\InventorySalesApi\StockResolver\AdaptStockResolverToAdminWebsitePlugin\aroundExecute
aroundExecute(GetStockBySalesChannelInterface $getStockBySalesChannel, callable $proceed, SalesChannelInterface $salesChannel)
Definition:
AdaptStockResolverToAdminWebsitePlugin.php:52
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
Definition:
SalesChannelInterface.php:17
Magento\Store\Api\Data\WebsiteInterface
Definition:
WebsiteInterface.php:14
Magento\InventoryCatalogApi\Api\DefaultStockProviderInterface
Definition:
DefaultStockProviderInterface.php:15
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\getCode
getCode()