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
CatalogInventory
Api
StockRegistry
AdaptGetProductStockStatusBySkuPlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Plugin\CatalogInventory\Api\StockRegistry
;
9
10
use
Magento\CatalogInventory\Api\StockRegistryInterface
;
11
use
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
;
12
use
Magento\InventorySalesApi\Api\IsProductSalableInterface
;
13
use
Magento\InventorySalesApi\Api\StockResolverInterface
;
14
use
Magento\Store\Model\StoreManagerInterface
;
15
19
class
AdaptGetProductStockStatusBySkuPlugin
20
{
24
private
$isProductSalable;
25
29
private
$storeManager;
30
34
private
$stockResolver;
35
41
public
function
__construct
(
42
IsProductSalableInterface
$isProductSalable,
43
StoreManagerInterface
$storeManager,
44
StockResolverInterface
$stockResolver
45
) {
46
$this->isProductSalable = $isProductSalable;
47
$this->storeManager =
$storeManager
;
48
$this->stockResolver = $stockResolver;
49
}
50
59
public
function
aroundGetProductStockStatusBySku
(
60
StockRegistryInterface
$subject,
61
callable $proceed,
62
$productSku,
63
$scopeId =
null
64
): int {
65
$websiteCode
=
null
=== $scopeId
66
? $this->storeManager->getWebsite()->getCode()
67
: $this->storeManager->getWebsite($scopeId)->getCode();
68
$stockId = $this->stockResolver->execute(
SalesChannelInterface::TYPE_WEBSITE
,
$websiteCode
)->getStockId();
69
70
return
(
int
)$this->isProductSalable->execute($productSku, $stockId);
71
}
72
}
Magento\InventorySalesApi\Api\IsProductSalableInterface
Definition:
IsProductSalableInterface.php:15
Magento\InventorySalesApi\Api\StockResolverInterface
Definition:
StockResolverInterface.php:15
$storeManager
$storeManager
Definition:
paypal_quote.php:14
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\TYPE_WEBSITE
const TYPE_WEBSITE
Definition:
SalesChannelInterface.php:29
Magento\Store\Model\StoreManagerInterface
Definition:
StoreManagerInterface.php:17
Magento\InventoryCatalog\Plugin\CatalogInventory\Api\StockRegistry\AdaptGetProductStockStatusBySkuPlugin\__construct
__construct(IsProductSalableInterface $isProductSalable, StoreManagerInterface $storeManager, StockResolverInterface $stockResolver)
Definition:
AdaptGetProductStockStatusBySkuPlugin.php:41
Magento\InventoryCatalog\Plugin\CatalogInventory\Api\StockRegistry\AdaptGetProductStockStatusBySkuPlugin\aroundGetProductStockStatusBySku
aroundGetProductStockStatusBySku(StockRegistryInterface $subject, callable $proceed, $productSku, $scopeId=null)
Definition:
AdaptGetProductStockStatusBySkuPlugin.php:59
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
Definition:
SalesChannelInterface.php:17
Magento\CatalogInventory\Api\StockRegistryInterface
Definition:
StockRegistryInterface.php:17
Magento\InventoryCatalog\Plugin\CatalogInventory\Api\StockRegistry
Definition:
AdaptGetProductStockStatusBySkuPlugin.php:8
$websiteCode
if(!isset($_GET['website_code'])) $websiteCode
Definition:
website.php:11
Magento\InventoryCatalog\Plugin\CatalogInventory\Api\StockRegistry\AdaptGetProductStockStatusBySkuPlugin
Definition:
AdaptGetProductStockStatusBySkuPlugin.php:19