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-review
Controller
Adminhtml
Product
JsonProductInfo.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Review\Controller\Adminhtml\Product
;
7
8
use
Magento\Framework\App\Action\HttpGetActionInterface
;
9
use
Magento\Review\Controller\Adminhtml\Product
as
ProductController
;
10
use
Magento\Backend\App\Action\Context
;
11
use
Magento\Framework\Registry
;
12
use Magento\Review\Model\ReviewFactory;
13
use Magento\Review\Model\RatingFactory;
14
use
Magento\Catalog\Api\ProductRepositoryInterface
;
15
use
Magento\Framework\DataObject
;
16
use
Magento\Framework\Controller\ResultFactory
;
17
18
class
JsonProductInfo
extends
ProductController
implements
HttpGetActionInterface
19
{
23
protected
$productRepository
;
24
32
public
function
__construct
(
33
Context
$context,
34
Registry
$coreRegistry
,
35
ReviewFactory
$reviewFactory
,
36
RatingFactory
$ratingFactory
,
37
ProductRepositoryInterface
$productRepository
38
) {
39
$this->productRepository =
$productRepository
;
40
parent::__construct($context,
$coreRegistry
,
$reviewFactory
,
$ratingFactory
);
41
}
42
46
public
function
execute
()
47
{
48
$response
=
new
DataObject
();
49
$id
= $this->
getRequest
()->getParam(
'id'
);
50
if
(intval(
$id
) > 0) {
51
$product
= $this->productRepository->getById(
$id
);
52
$response
->setId(
$id
);
53
$response
->addData(
$product
->getData());
54
$response
->setError(0);
55
}
else
{
56
$response
->setError(1);
57
$response
->setMessage(
__
(
'We can\'t retrieve the product ID.'
));
58
}
60
$resultJson = $this->resultFactory->create(
ResultFactory::TYPE_JSON
);
61
$resultJson->setData(
$response
->toArray());
62
return
$resultJson;
63
}
64
}
Magento\Framework\Controller\ResultFactory\TYPE_JSON
const TYPE_JSON
Definition:
ResultFactory.php:22
$response
$response
Definition:
404.php:11
Magento\Framework\App\Action\HttpGetActionInterface
Definition:
HttpGetActionInterface.php:16
Magento\Review\Controller\Product\$coreRegistry
$coreRegistry
Definition:
Product.php:25
$id
$id
Definition:
fieldset.phtml:14
Magento\Review\Controller\Adminhtml\Product\JsonProductInfo
Definition:
JsonProductInfo.php:18
Magento\Framework\Controller\ResultFactory
Definition:
ResultFactory.php:17
__
__()
Definition:
__.php:13
Magento\Review\Controller\Adminhtml\Product\JsonProductInfo\$productRepository
$productRepository
Definition:
JsonProductInfo.php:23
Magento\Framework\DataObject
Definition:
DataObject.php:15
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\Review\Controller\Product\$ratingFactory
$ratingFactory
Definition:
Product.php:74
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
Magento\Framework\App\ActionInterface\execute
execute()
Magento\Review\Controller\Product
Definition:
ListAction.php:6
Magento\Review\Controller\Adminhtml\Product
Definition:
Delete.php:6
Magento\Backend\App\Action\Context
Definition:
Context.php:25
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\Review\Controller\Adminhtml\Product\JsonProductInfo\__construct
__construct(Context $context, Registry $coreRegistry, ReviewFactory $reviewFactory, RatingFactory $ratingFactory, ProductRepositoryInterface $productRepository)
Definition:
JsonProductInfo.php:32
Magento\Framework\Registry
Definition:
Registry.php:18
Magento\Review\Controller\Product\$reviewFactory
$reviewFactory
Definition:
Product.php:67
Magento\Framework\DataObject
Definition:
Cache.php:6