From 4f5bf91d71396581671eab5b84196036fa77a104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Wac=C5=82awczyk?= Date: Mon, 8 Jul 2024 14:53:47 +0200 Subject: [PATCH] #104362 add admin snowmenu/node/productName controller --- Controller/Adminhtml/Node/ProductName.php | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Controller/Adminhtml/Node/ProductName.php diff --git a/Controller/Adminhtml/Node/ProductName.php b/Controller/Adminhtml/Node/ProductName.php new file mode 100644 index 00000000..259e01e5 --- /dev/null +++ b/Controller/Adminhtml/Node/ProductName.php @@ -0,0 +1,49 @@ +productRepository = $productRepository; + } + + /** + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\InputException + */ + public function execute() + { + $storeId = (int) $this->_request->getParam('store_id', 0); + $productId = $this->_request->getParam('product_id'); + if (empty($productId)) { + throw new InputException(__("Missing required product_id param")); + } + $product = $this->productRepository->getById($productId, false, $storeId); + $result = $this->resultFactory->create(ResultFactory::TYPE_JSON); + + return $result->setData(['product_name' => $product->getName()]); + } +}