Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AdaptAddStockStatusToSelectPlugin.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
17 
22 {
26  private $stockResolver;
27 
31  private $addStockStatusToSelect;
32 
37  public function __construct(
38  StockResolverInterface $stockResolver,
39  AddStockStatusToSelect $addStockStatusToSelect
40  ) {
41  $this->stockResolver = $stockResolver;
42  $this->addStockStatusToSelect = $addStockStatusToSelect;
43  }
44 
55  Status $stockStatus,
56  callable $proceed,
59  ) {
60  $websiteCode = $website->getCode();
61  if (null === $websiteCode) {
62  throw new LocalizedException(__('Website code is empty'));
63  }
64 
65  $stock = $this->stockResolver->execute(SalesChannelInterface::TYPE_WEBSITE, $websiteCode);
66  $stockId = (int)$stock->getStockId();
67 
68  $this->addStockStatusToSelect->execute($select, $stockId);
69 
70  return $stockStatus;
71  }
72 }
__()
Definition: __.php:13
$stock
if(!isset($_GET['website_code'])) $websiteCode
Definition: website.php:11