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
Model
ResourceModel
Stock
Status
AdaptAddStockStatusToSelectPlugin.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status
;
9
10
use
Magento\CatalogInventory\Model\ResourceModel\Stock\Status
;
11
use
Magento\Framework\DB\Select
;
12
use
Magento\Framework\Exception\LocalizedException
;
13
use
Magento\InventoryCatalog\Model\ResourceModel\AddStockStatusToSelect
;
14
use
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
;
15
use
Magento\InventorySalesApi\Api\StockResolverInterface
;
16
use
Magento\Store\Model\Website
;
17
21
class
AdaptAddStockStatusToSelectPlugin
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
54
public
function
aroundAddStockStatusToSelect
(
55
Status
$stockStatus,
56
callable $proceed,
57
Select
$select
,
58
Website
$website
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
}
Magento\Framework\DB\Select
Definition:
Select.php:33
Magento\CatalogInventory\Model\ResourceModel\Stock\Status
Definition:
Collection.php:7
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\InventorySalesApi\Api\StockResolverInterface
Definition:
StockResolverInterface.php:15
$website
$website
Definition:
payment_configuration_rollback.php:38
Magento\Store\Model\Website
Definition:
Website.php:26
Magento\InventoryCatalog\Model\ResourceModel\AddStockStatusToSelect
Definition:
AddStockStatusToSelect.php:17
__
__()
Definition:
__.php:13
Magento\InventorySalesApi\Api\Data\SalesChannelInterface\TYPE_WEBSITE
const TYPE_WEBSITE
Definition:
SalesChannelInterface.php:29
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status
Definition:
AdaptAddIsInStockFilterToCollectionPlugin.php:8
Magento\InventorySalesApi\Api\Data\SalesChannelInterface
Definition:
SalesChannelInterface.php:17
Magento\CatalogInventory\Model\ResourceModel\Stock\Status
Definition:
Status.php:21
Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockStatusToSelectPlugin\aroundAddStockStatusToSelect
aroundAddStockStatusToSelect(Status $stockStatus, callable $proceed, Select $select, Website $website)
Definition:
AdaptAddStockStatusToSelectPlugin.php:54
$stock
$stock
Definition:
product_alert.php:22
Magento\Framework\DB\Select
Definition:
ColumnsRenderer.php:6
Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockStatusToSelectPlugin\__construct
__construct(StockResolverInterface $stockResolver, AddStockStatusToSelect $addStockStatusToSelect)
Definition:
AdaptAddStockStatusToSelectPlugin.php:37
$websiteCode
if(!isset($_GET['website_code'])) $websiteCode
Definition:
website.php:11
Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockStatusToSelectPlugin
Definition:
AdaptAddStockStatusToSelectPlugin.php:21