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
Model
Stock
Command
Get.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\Inventory\Model\Stock\Command
;
9
10
use
Magento\Framework\Exception\NoSuchEntityException
;
11
use
Magento\Inventory\Model\ResourceModel\Stock
as
StockResourceModel
;
12
use
Magento\InventoryApi\Api\Data\StockInterface
;
13
use Magento\InventoryApi\Api\Data\StockInterfaceFactory;
14
18
class
Get
implements
GetInterface
19
{
23
private
$stockResource;
24
28
private
$stockFactory;
29
34
public
function
__construct
(
35
StockResourceModel
$stockResource,
36
StockInterfaceFactory $stockFactory
37
) {
38
$this->stockResource = $stockResource;
39
$this->stockFactory =
$stockFactory
;
40
}
41
45
public
function
execute
(
int
$stockId):
StockInterface
46
{
48
$stock
= $this->stockFactory->create();
49
$this->stockResource->load(
$stock
, $stockId,
StockInterface::STOCK_ID
);
50
51
if
(
null
===
$stock
->getStockId()) {
52
throw
new
NoSuchEntityException
(
__
(
'Stock with id "%value" does not exist.'
, [
'value'
=> $stockId]));
53
}
54
return
$stock
;
55
}
56
}
Magento\InventoryApi\Api\Data\StockInterface\STOCK_ID
const STOCK_ID
Definition:
StockInterface.php:22
Magento\InventoryApi\Api\Data\StockInterface
Definition:
StockInterface.php:17
__
__()
Definition:
__.php:13
Magento\Inventory\Model\Stock\Command
Definition:
DeleteById.php:8
Magento\Inventory\Model\Stock\Command\Get
Definition:
Get.php:18
Magento\Inventory\Model\ResourceModel\Stock
Definition:
Collection.php:8
$stockFactory
$stockFactory
Definition:
stock.php:15
$stock
$stock
Definition:
product_alert.php:22
Magento\Inventory\Model\Stock\Command\GetInterface
Definition:
GetInterface.php:23
Magento\Inventory\Model\Stock\Command\Get\__construct
__construct(StockResourceModel $stockResource, StockInterfaceFactory $stockFactory)
Definition:
Get.php:34
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16
Magento\Inventory\Model\Stock\Command\GetInterface\execute
execute(int $stockId)