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-product-alert
Plugin
AdaptProductSalabilityPlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryProductAlert\Plugin
;
9
10
use
Magento\Catalog\Api\Data\ProductInterface
;
11
use
Magento\Framework\Exception\NoSuchEntityException
;
12
use
Magento\InventoryApi\Api\Data\StockInterface
;
13
use
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
;
14
use
Magento\InventorySalesApi\Api\IsProductSalableInterface
;
15
use
Magento\InventorySalesApi\Api\StockResolverInterface
;
16
use
Magento\ProductAlert\Model\ProductSalability
;
17
use
Magento\Store\Api\Data\WebsiteInterface
;
18
22
class
AdaptProductSalabilityPlugin
23
{
27
private
$stockResolver;
28
32
private
$isProductSalable;
33
38
public
function
__construct
(
39
StockResolverInterface
$stockResolver,
40
IsProductSalableInterface
$isProductSalable
41
) {
42
$this->stockResolver = $stockResolver;
43
$this->isProductSalable = $isProductSalable;
44
}
45
56
public
function
aroundIsSalable(
57
ProductSalability
$productSalability,
58
callable $proceed,
59
ProductInterface
$product
,
60
WebsiteInterface
$website
61
): bool {
63
$stock
= $this->stockResolver->execute(
SalesChannelInterface::TYPE_WEBSITE
,
$website
->getCode());
64
$isSalable = $this->isProductSalable->execute(
$product
->getSku(), (int)
$stock
->getStockId());
65
66
return
$isSalable;
67
}
68
}
Magento\InventorySalesApi\Api\IsProductSalableInterface
Definition:
IsProductSalableInterface.php:15
Magento\InventorySalesApi\Api\StockResolverInterface
Definition:
StockResolverInterface.php:15
Magento\InventoryApi\Api\Data\StockInterface
Definition:
StockInterface.php:17
$website
$website
Definition:
payment_configuration_rollback.php:38
Magento\InventoryProductAlert\Plugin
Definition:
AdaptProductSalabilityPlugin.php:8
Magento\InventoryProductAlert\Plugin\AdaptProductSalabilityPlugin
Definition:
AdaptProductSalabilityPlugin.php:22
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\TYPE_WEBSITE
const TYPE_WEBSITE
Definition:
SalesChannelInterface.php:29
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
Definition:
SalesChannelInterface.php:17
Magento\Store\Api\Data\WebsiteInterface
Definition:
WebsiteInterface.php:14
Magento\ProductAlert\Model\ProductSalability
Definition:
ProductSalability.php:16
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
$stock
$stock
Definition:
product_alert.php:22
Magento\InventoryProductAlert\Plugin\AdaptProductSalabilityPlugin\__construct
__construct(StockResolverInterface $stockResolver, IsProductSalableInterface $isProductSalable)
Definition:
AdaptProductSalabilityPlugin.php:38
Magento\Catalog\Api\Data\ProductInterface
Definition:
ProductInterface.php:14
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16