Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [json]

This tag should be used for questions related to json data types

22
votes
9answers
34k views

How to update magento2 from 2.0.0 to 2.0.2

The docs here say that you should use the system upgrade utility: http://devdocs.magento.com/guides/v2.0/comp-mgr/upgrader/upgrade-start.html and do it from the admin. I thought that you would be ...
8
votes
0answers
825 views

API Stock update

Using Magento 2.2.2, I was trying to add stock updates to a pre-existing setup using the official defined endpoint: rest/V1/products/testsku/stockItems/1 with { "stock_item": { "qty": 1234, ...
7
votes
4answers
18k views

How do I get a response from REST API in JSON format in Magento 2?

I used the resources in “Creating a New REST Web Service in Magento 2” and “Creating a New REST Web Service in Magento 2” to create a custom API module, but the response is in XML format. I need a ...
7
votes
4answers
2k views

Creating a custom module to send order details to external supplier API via XML or JSON

I'm trying to write a custom module for Magento that when certain items are ordered and payment has been made, posts to our clothing supplier's site with details of the ordered item, delivery address ...
5
votes
3answers
19k views

Magento2 - How to get JSON response from Controller [closed]

I've created my custom controller and I want to return the result formated with JSON. I always get a JSON parse error "JSON.parse: unexpected character at line 1 column 1 of the JSON data" and the ...
4
votes
4answers
5k views

Magento 1.9.3.3 - How do you return a JSON array from a controller to ajax

I have a ajax call to a controller (suburbSearchAction) which retrieves a list of suburbs based suburb text received from the user Ajax call inputSuburbData = jQuery(inputSuburb).val().trim(); ...
4
votes
3answers
3k views

how to create grid using ui component with multi table(JOIN) in magento2?

I have created a grid with UI component with one table now I want to join another table so how can I create?? i try but not working in Vendorname\Modulename\Model\ResourceModel\Quote\collection.php ...
4
votes
3answers
3k views

No response from POST to custom REST Api route

I set up a working custom route for Magento's REST Api. It works fine for GET requests, as the _retrieve() function of the corresponding V1.php class is being called as expected and returns the data. ...
4
votes
2answers
1k views

Magento 2 - How to get JSON response from Controller

I've created my custom controller and I want to return the result formated with JSON. I always get a JSON: [] Route: <route url="/V1/points/get" method="GET"> <service class="module\...
3
votes
2answers
390 views

Magento 2.3 use of `db_schema_whitelist.json` file in etc directory of each module

What is the use of db_schema_whitelist.json located in Magento Catalog etc directory? In Magento 2.3 version, I found db_schema_whitelist.json and db_schema.xml files, in the Magento_Catalog module. ...
3
votes
3answers
2k views

How to get json data on frontend controller in magento2?

<?php namespace Vendor\Module\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $resultPageFactory; public function __construct( \Magento\...
3
votes
1answer
56 views

How to avoid using php://input?

I have a POST endpoint that receives a JSON payload. I'm using the Magento\Framework\App\Request\Http class to try and retrieve my POST data. If I run $data = $this->request->getPost();, ...
3
votes
1answer
742 views

how i update the order status in controller in magento 2?

<?php namespace Vendor\Module\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\App\ResponseInterface;class Index extends ...
3
votes
1answer
1k views

Magento 2: Intercept controller's JSON response

I'm trying to intercept a controller returning a JSON object of Magento\Framework\Controller\Result\Json class. The problem is that no matter if I use a plugin or a preference to "catch" the ...
3
votes
2answers
3k views

Price not updating on Configurable products after upgrade to Magento 1.9.3

I think I may have found a bug in Magento CE 1.9.3 which was released last week? I upgraded our Staging environment to it and have found that the pricing of Configurable products is not updating ...
3
votes
1answer
83 views

Magento 2 Unexpected number in JSON at position 1

Am working on magento 2.3 and have an error in console product page,i have no idea what is it,i guess its fetching json data with error in product gallery part. I tried every thing like clearing ...
3
votes
1answer
266 views

How to pass a json data from Observer to phtml

Upon Login, I am sending an API call(post request) to an external site in observer which return a JSON response. I need to populate a table in the phtml with the response received. Hence I am trying ...
3
votes
0answers
428 views

Reset super-attributes in select drop down for configurable products [closed]

Currently I have 2 select options: size and color as dropdown menus for my configurable products. On the frontend, users can select size, then color. Options for color are greyed out accordingly if ...
2
votes
3answers
750 views

I have one json file of all products, and now I want to display only those products of current categories?

$baseUrl = $this->getBaseUrl(); $skinUrl = $this->getSkinUrl(); $currcategory = Mage::getSingleton('catalog/layer')->getCurrentCategory(); $products = file_get_contents('c_node.json'); $arr = ...
2
votes
2answers
2k views

Alphabetically Sort The State/Province Drop Down

I have an issue in sorting alphabetically those items in the state/region drop down. // File: Mage/Directory/Helper/Data.php (line:150) $json = Mage::helper('core')->jsonEncode($regions); Mage::...
2
votes
3answers
6k views

Magento2: How to convert JSON to Array of nested objects

I am wanting to understand if there are some functions in Magento Framework which will assist me in mapping an array of nested objects from JSON (such as what would happen when the REST API is ...
2
votes
2answers
5k views

Force JSON Encode to Return Object

As far as I understand, Magento has a JSON encode function by using zend framework. And my question, is there an option to force that function always return JSON object, not JSON array? Mage::helper('...
2
votes
1answer
352 views

How can I get the value of array object?

Im try to pass sql query value as an AJAX request, It have a array object I need to pass only the value, below code for that public function execute() { $resultJson = $this->resultJsonFactory-...
2
votes
1answer
5k views

Properly convert Magento's returned object to JSON

I made a customer log-in to the site programmatically... I am properly returned the session values in form of an object. Now i want this data carried over and returned from the function in JSON ...
2
votes
2answers
99 views

How to overwrite .php file of lib directory?

Any one tell me how i can overwrite this file in magento 2.3 Path: Magento2\lib\internal\Magento\Framework\Webapi\Rest\Response\Renderer\Json.php
2
votes
1answer
738 views

Magento 2: how to debug json error

After a while of developing (with a colleague) I get this JS error on every page: "SyntaxError: JSON.parse: unexpected character at line 5 column 50 of the JSON data" in file main.js. This is nice to ...
2
votes
1answer
1k views

Magento 2 - Send processed data from Controller to PHTML

I am working on a simple custom module, where the user can input height and the weight/BMI will be shown as output on form submit. On clicking the submit button user will be redirected to different ...
2
votes
2answers
466 views

Serialized array in controller

This is my script <script> function callAjax(){ var customoptionhtml = document.getElementById("customoption-dynamic").innerHTML; //alert(test);//alert(jQuery(test).text()); var ...
2
votes
1answer
2k views

KnockoutJS cannot read property 'fromJS' of undefined

I have tried bind json file with knockoutjs into my custom template. But i got this error in browser console: Uncaught TypeError: Cannot read property 'fromJS' of undefined How to avoid this error?...
2
votes
1answer
2k views

Format Cart Totals HTML from JSON Response

My Controller File public function myAction() { $response = array(); $response['myresponse'] = $this->myAjax(); $this->getResponse()->clearHeaders()->setHeader('...
2
votes
0answers
47 views

Magento 2.3.1 JSON.parse: unterminated string at line 2 column 1009

I am unable to set payment method in Magento 2.3.1. As soon as I click on the payment method button all JavaScript functions are killed. open error log nothing to show, but browser console point me ...
2
votes
1answer
22 views

JSON API “website_id” in tier price create

I've already got products and stock updates going back and forth via the JSON API, and I'm now working on orders and prices for each store view - each one has a different currency, therefore different ...
2
votes
0answers
145 views

How to find Magento version using API (JSON specifically)

Using the JSON RestAPI, I need to do things slightly differently depending on the version of Magento due to as-yet un-fixed bugs (specifically https://github.com/magento/magento2/issues/18005). I can ...
2
votes
1answer
797 views

Magento 2.2.2, Unable to unserialize value, magento_umask and edting Json.php did not help

After upgrade I'm getting below error in my local : Exception #0 (InvalidArgumentException): Unable to unserialize value. #0 myPath/vendor/magento/module-theme/Controller/Result/MessagePlugin.php(...
2
votes
2answers
2k views

Magento 2 how to unserialize backend config

I've created Magento 2 module that saves a particular configuration. Screenshot: Now I want to use this value in a frontend block. If I check the core_config table, the value is saved like this: a:1:...
2
votes
2answers
434 views

how i get the json body in controller in magento 2?

<?php namespace VEndor\Module\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $resultPageFactory; public function __construct( \Magento\...
2
votes
1answer
37 views

Quickcreate JSON error

Using the quick-create-product option on Configurable Products gives an error. An AJAX call is made, the product is created but the JSON response is wrong. So the 'Please wait' overlay stays and the ...
2
votes
1answer
524 views

Why doesn't Magento setHeader('application/json') when appropriate in OnePageCheckout?

I have a Magento environment that is tunneled through Apache via mod_proxy. During the one-page checkout process, Apache is erroneously wrapping JSON responses in HTML because the response header says ...
2
votes
0answers
120 views

curl and json approve conversion Rest API

i'm currently coding a little api for extole approve conversion api. It's only suppose to send data on declined orders which is equal to cancelled in the magento admin. Here is what i have written ...
1
vote
3answers
4k views

“Zend_Json Decoding failed: syntax error” when submitting order

I recently switched from Apache/PHP 5.5 to a new nginx/PHP 7.0.4 server and now I am getting once in a while a "Decoding failed: Syntax error" when customers try to checkout, apparently when they ...
1
vote
1answer
445 views

Magento 2: How can I store my original REST request in a file on the server?

I need to store my REST request within the file system - I have tried serializing the request object, but obviously the file size is quite a lot larger than the original. I have run a test that ...
1
vote
1answer
255 views

How echo json data in a Magento controller on a valid way?

I have created a Magento plugin. In this plugin I call (with ajax) a custom controller where I echo some json data: public function testAction() { echo json_encode('test'); exit; } But when I ...
1
vote
1answer
164 views

js-translation.json fails to generated

Magento 2.1 We have a site setup with both English and French languages. We were noticing some french translations weren't showing on checkout page. Upon further inspection js-translation.json was ...
1
vote
3answers
4k views

How can i get image url with proper path?

<?php foreach ($temp as $product): ?> <?php $id = $product['entity_id']; $img = $product['image']; $url = $product['url_path']; $small_image = $skinUrl.$product['small_image']...
1
vote
1answer
157 views

Add category description to “catalog/category_tree” collection

class Ab_CategoryObserver_Model_Observer { public function updateTopMenuJson(Varien_Event_Observer $observer) { $_helper = Mage::helper('catalog/category'); $_categories = $...
1
vote
1answer
184 views

something is wrong in the code. theows an error->getNodeChildrenData() must be an instance of Varien_Data_Tree_Node,on line 18 [duplicate]

<?php class Ab_CategoryObserver_Model_Observer{ public function updateTopMenuJson(Varien_Event_Observer $observer){ $_helper = Mage::helper('catalog/category'); $_categories = $...
1
vote
1answer
910 views

Magento 2: how to get json posted data in payment method

Magento is posting payment detail in json format on rest/default/V1/carts/mine/payment-information Method post {"cartId":"3","billingAddress":{"countryId":"US","regionId":"0","postcode":null,"...
1
vote
1answer
35 views

How to use resultJsonFactory in Model file magento2

I have used below code to print response from my Model file. <?php class CountrylistManagement implements \Vendor\Module\Api\CountrylistManagementInterface { protected $_storeManager; ...
1
vote
1answer
33 views

Create order data json file in root after checkout is completed

I want a json file of order data to be created in root directory after the checkout is completed. I have been searching this for hours now but still luck.
1
vote
2answers
1k views

Magento2 Uncaught SyntaxError: Unexpected token B in JSON at position 121

Product detail page showing this error for some products Uncaught SyntaxError: Unexpected token B in JSON at position 121<br> at JSON.parse (<anonymous>) at getData (main.js:58) ...