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-admin-ui
Controller
Adminhtml
Stock
Edit.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryAdminUi\Controller\Adminhtml\Stock
;
9
10
use
Magento\Backend\App\Action
;
11
use
Magento\Backend\App\Action\Context
;
12
use
Magento\Backend\Model\View\Result\Page
;
13
use
Magento\Framework\Controller\Result\Redirect
;
14
use
Magento\Framework\Controller\ResultFactory
;
15
use
Magento\Framework\Controller\ResultInterface
;
16
use
Magento\Framework\Exception\NoSuchEntityException
;
17
use
Magento\InventoryApi\Api\Data\StockInterface
;
18
use
Magento\InventoryApi\Api\StockRepositoryInterface
;
19
use
Magento\Framework\App\Action\HttpGetActionInterface
;
20
24
class
Edit
extends
Action
implements
HttpGetActionInterface
25
{
29
const
ADMIN_RESOURCE
=
'Magento_InventoryApi::stock'
;
30
34
private
$stockRepository;
35
40
public
function
__construct
(
41
Context
$context,
42
StockRepositoryInterface
$stockRepository
43
) {
44
parent::__construct($context);
45
$this->stockRepository =
$stockRepository
;
46
}
47
51
public
function
execute
():
ResultInterface
52
{
53
$stockId = (int)$this->
getRequest
()->getParam(
StockInterface::STOCK_ID
);
54
try
{
55
$stock
= $this->stockRepository->get($stockId);
56
58
$result
= $this->resultFactory->create(
ResultFactory::TYPE_PAGE
);
59
$result
->setActiveMenu(
'Magento_InventoryApi::stock'
)
60
->addBreadcrumb(
__
(
'Edit Stock'
),
__
(
'Edit Stock'
));
61
$result
->getConfig()
62
->getTitle()
63
->prepend(
__
(
'Edit Stock: %name'
, [
'name'
=>
$stock
->getName()]));
64
}
catch
(NoSuchEntityException $e) {
66
$result
= $this->resultRedirectFactory->create();
67
$this->messageManager->addErrorMessage(
68
__
(
'Stock with id "%value" does not exist.'
, [
'value'
=> $stockId])
69
);
70
$result
->setPath(
'*/*'
);
71
}
72
73
return
$result
;
74
}
75
}
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Framework\App\Action\HttpGetActionInterface
Definition:
HttpGetActionInterface.php:16
Magento\InventoryApi\Api\StockRepositoryInterface
Definition:
StockRepositoryInterface.php:26
Magento\InventoryApi\Api\Data\StockInterface\STOCK_ID
const STOCK_ID
Definition:
StockInterface.php:22
Magento\InventoryApi\Api\Data\StockInterface
Definition:
StockInterface.php:17
Magento\InventoryAdminUi\Controller\Adminhtml\Stock\Edit
Definition:
Edit.php:24
Magento\Framework\Controller\ResultFactory
Definition:
ResultFactory.php:17
__
__()
Definition:
__.php:13
Magento\Framework\Controller\ResultInterface
Definition:
ResultInterface.php:19
Magento\Framework\Controller\Result\Redirect
Definition:
Redirect.php:22
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\InventoryAdminUi\Controller\Adminhtml\Stock\Edit\ADMIN_RESOURCE
const ADMIN_RESOURCE
Definition:
Edit.php:29
Magento\Framework\App\ActionInterface\execute
execute()
Magento\Backend\App\Action
Definition:
Action.php:17
Magento\InventoryAdminUi\Controller\Adminhtml\Stock\Edit\__construct
__construct(Context $context, StockRepositoryInterface $stockRepository)
Definition:
Edit.php:40
Magento\InventoryAdminUi\Controller\Adminhtml\Stock
Definition:
Delete.php:8
$stockRepository
$stockRepository
Definition:
stock.php:19
Magento\Backend\App\Action\Context
Definition:
Context.php:25
$stock
$stock
Definition:
product_alert.php:22
Magento\Framework\Controller\ResultFactory\TYPE_PAGE
const TYPE_PAGE
Definition:
ResultFactory.php:27
Magento\Backend\App\Action
Definition:
Context.php:6
Magento\Backend\Model\View\Result\Page
Definition:
Page.php:15
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16