Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AjaxLoad.php
Go to the documentation of this file.
1 <?php
9 
12 
14 {
21  public function execute()
22  {
23  $rateId = (int)$this->getRequest()->getParam('id');
24  try {
25  /* @var \Magento\Tax\Api\Data\TaxRateInterface */
26  $taxRateDataObject = $this->_taxRateRepository->get($rateId);
27  /* @var array */
28  $resultArray = $this->_taxRateConverter->createArrayFromServiceObject($taxRateDataObject, true);
29 
30  $responseContent = [
31  'success' => true,
32  'error_message' => '',
33  'result' => $resultArray,
34  ];
35  } catch (NoSuchEntityException $e) {
36  $responseContent = [
37  'success' => false,
38  'error_message' => $e->getMessage(),
39  ];
40  } catch (\Exception $e) {
41  $responseContent = [
42  'success' => false,
43  'error_message' => __('An error occurred while loading this tax rate.'),
44  ];
45  }
46 
48  $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
49  $resultJson->setData($responseContent);
50  return $resultJson;
51  }
52 }
__()
Definition: __.php:13