Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AdaptProductSalabilityPlugin.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
18 
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,
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 }
$stock
__construct(StockResolverInterface $stockResolver, IsProductSalableInterface $isProductSalable)