![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-review/Controller/Adminhtml/Product/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Review\Controller\Adminhtml\Product; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Review\Controller\Adminhtml\Product as ProductController; use Magento\Backend\App\Action\Context; use Magento\Framework\Registry; use Magento\Review\Model\ReviewFactory; use Magento\Review\Model\RatingFactory; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\DataObject; use Magento\Framework\Controller\ResultFactory; /** * Represents product info in json */ class JsonProductInfo extends ProductController implements HttpGetActionInterface { /** * @var \Magento\Catalog\Api\ProductRepositoryInterface */ protected $productRepository; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ public function __construct( Context $context, Registry $coreRegistry, ReviewFactory $reviewFactory, RatingFactory $ratingFactory, ProductRepositoryInterface $productRepository ) { $this->productRepository = $productRepository; parent::__construct($context, $coreRegistry, $reviewFactory, $ratingFactory); } /** * Execute controller * * @return \Magento\Framework\Controller\Result\Json */ public function execute() { $response = new DataObject(); $id = $this->getRequest()->getParam('id'); if ((int)$id > 0) { $product = $this->productRepository->getById($id); $response->setId($id); $response->addData($product->getData()); $response->setError(0); } else { $response->setError(1); $response->setMessage(__('We can\'t retrieve the product ID.')); } /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); $resultJson->setData($response->toArray()); return $resultJson; } }