could not validate a connection to Elasticsearch. No alive nodes found in your cluster

manually add “elasticsearch” to node <elasticsearch7_server_hostname> in vendor/magento/module-elasticsearch-7/etc/config.xml disable elasticsearch6 and enable elasticsearch7 module bin/magento module:enable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch(version)} bin/magento module:disable Magento_Elasticsearch(previous version)

Published
Categorized as Magento

How to encode and decode JSON in PHP?

decode <?php $student_data= ‘{“Ram”:96,”Prashant”:76,”Varun”:65,”Mark”:34}’;// Decoding above JSON String into JSON object$decoded= json_decode($student_data);// Dump the $decoded variablevar_dump($decoded);?> encode <?php// PHP associative array$student_data= array(“Ram”=>96, “Prashant”=>76, “Varun”=>65, “Mark”=>34);// Encoding PHP Associative array using json_encode()$encoded= json_encode($student_data);// Echo the dataecho$encoded;?> Output: {“Ram”:96,”Prashant”:76,”Varun”:65,”Mark”:34}

Published
Categorized as Magento

How to covert file to base64

in custom javascript: function setInputValue(element) { var file = element.files[0]; var reader = new FileReader(); reader.onloadend = function() { console.log(‘RESULT’, reader.result) console.log(this.result); buttonbase64=this.result; }reader.readAsDataURL(file);} var base = buttonbase64; in phtml file : <input id=”upload” type=”file” onchange=”encodePdfFileAsURL(this)” name=”uploadbutton” accept=”.pdf”>

Published
Categorized as Magento

How to decode the response and get the data from response.

$response = curl_exec($curl); $jsonArray = json_decode($response, true); if($jsonArray[‘status’] == 200) { $responseArray=$jsonArray[‘response’]; $freight_option=$responseArray[‘freight_option’]; $freight_minimum_amount=$responseArray[‘freight_minimum_amount’]; }

Published
Categorized as Magento

How to call block function in template file.

<?php$blockObj= $block->getLayout()->createBlock(‘JJ\Paymentinformation\Block\Main’);$data= $blockObj->getMyCustomMethod();?> And which block u want call in that div add <p class=”cash-amount”><?=$data[‘credit-limit’];?>

Published
Categorized as Magento

Install stripe issue resolved

Issue- solution- In project folder vendor folder delete ->again create a vendor folder copy the htaccess file from magento vendor folder and paste in to the project vendor folder. Then open composer json file delete the svddevelopment line composer update ->upgrade->deploye then stripe is installed.

Published
Categorized as Magento