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-checkout
Controller
Sidebar
UpdateItemQty.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Checkout\Controller\Sidebar
;
7
8
use
Magento\Checkout\Model\Sidebar
;
9
use
Magento\Framework\App\Action\Action
;
10
use
Magento\Framework\App\Action\Context
;
11
use
Magento\Framework\App\Response\Http
;
12
use
Magento\Framework\Exception\LocalizedException
;
13
use
Magento\Framework\Json\Helper\Data
;
14
use Psr\Log\LoggerInterface;
15
16
class
UpdateItemQty
extends
Action
17
{
21
protected
$sidebar
;
22
26
protected
$logger
;
27
31
protected
$jsonHelper
;
32
40
public
function
__construct
(
41
Context
$context,
42
Sidebar
$sidebar
,
43
LoggerInterface
$logger
,
44
Data
$jsonHelper
45
) {
46
$this->sidebar =
$sidebar
;
47
$this->logger =
$logger
;
48
$this->jsonHelper =
$jsonHelper
;
49
parent::__construct($context);
50
}
51
55
public
function
execute
()
56
{
57
$itemId = (int)$this->
getRequest
()->getParam(
'item_id'
);
58
$itemQty = $this->
getRequest
()->getParam(
'item_qty'
) * 1;
59
60
try
{
61
$this->sidebar->checkQuoteItem($itemId);
62
$this->sidebar->updateQuoteItem($itemId, $itemQty);
63
return
$this->
jsonResponse
();
64
}
catch
(
LocalizedException
$e) {
65
return
$this->
jsonResponse
($e->getMessage());
66
}
catch
(\
Exception
$e) {
67
$this->logger->critical($e);
68
return
$this->
jsonResponse
($e->getMessage());
69
}
70
}
71
78
protected
function
jsonResponse
($error =
''
)
79
{
80
return
$this->
getResponse
()->representJson(
81
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error))
82
);
83
}
84
}
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\Framework\App\Response\Http
Definition:
FileFactory.php:7
Magento\Checkout\Controller\Sidebar\UpdateItemQty\$logger
$logger
Definition:
UpdateItemQty.php:26
Magento\Framework\App\Action\AbstractAction\getResponse
getResponse()
Definition:
AbstractAction.php:70
Magento\Checkout\Controller\Sidebar\UpdateItemQty
Definition:
UpdateItemQty.php:16
Magento\Checkout\Model\Sidebar
Definition:
Sidebar.php:18
Magento\Checkout\Controller\Sidebar\UpdateItemQty\__construct
__construct(Context $context, Sidebar $sidebar, LoggerInterface $logger, Data $jsonHelper)
Definition:
UpdateItemQty.php:40
Magento\Checkout\Controller\Sidebar\UpdateItemQty\$sidebar
$sidebar
Definition:
UpdateItemQty.php:21
Magento\Framework\Json\Helper\Data
Definition:
Data.php:13
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\Catalog\Model\Product\Exception
Definition:
Exception.php:14
Magento\Checkout\Controller\Sidebar\UpdateItemQty\execute
execute()
Definition:
UpdateItemQty.php:55
Magento\Checkout\Controller\Sidebar\UpdateItemQty\$jsonHelper
$jsonHelper
Definition:
UpdateItemQty.php:31
Magento\Checkout\Controller\Sidebar
Definition:
RemoveItem.php:6
Magento\Framework\App\Action\Context
Definition:
Context.php:24
Magento\Checkout\Controller\Sidebar\UpdateItemQty\jsonResponse
jsonResponse($error='')
Definition:
UpdateItemQty.php:78
Magento\Framework\App\Action\Action
Definition:
Action.php:25