Hot answers tagged

55 votes

How to update magento2 from 2.0.0 to 2.0.2

Updating/Upgrading to Magento 2.0.2 (via composer) php bin/magento maintenance:enable composer require magento/product-community-edition 2.0.2 --no-update composer update rm -rf var/di var/generation ...
Mukesh Chapagain's user avatar
34 votes

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

The db_schema_whitelist.json file is a way of telling Magento which tables and columns it can safely alter using the db_schema.xml file. It was added to preserve backward compatibility and will be ...
Daniel Kratohvil's user avatar
32 votes

Magento2 - How to get JSON response from Controller

If you want to send JSON response from a controller then you have to inject \Magento\Framework\Controller\Result\JsonFactory class to __construct(). See: /** * @var \Magento\Framework\...
Amit Bera's user avatar
  • 77.2k
32 votes

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

db_schema_whitelist.json file provides a history of all tables, columns, keys added with declarative schema. It can be generated manually or created automatically with the following command : php bin/...
Rohan Hapani's user avatar
  • 17.3k
20 votes
Accepted

How to update magento2 from 2.0.0 to 2.0.2

The recommended way in the documentation is via admin: System > Web Setup Wizard > System Upgrade. (http://devdocs.magento.com/guides/v2.0/comp-mgr/upgrader/upgrade-start.html) You must have ...
Claudiu Creanga's user avatar
19 votes

Magento2: How to convert JSON to Array of nested objects

\Magento\Framework\Json\Helper\Data is deprecated since Magento 100.2.0 You could use \Magento\Framework\Serialize\Serializer\Json instead. Ie. public function __construct( \Magento\...
diazwatson's user avatar
  • 2,410
18 votes

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

Below are the custom api module with key pair value To get JSON response, in client set Response headers to "Content-Type: application/json; charset=utf-8" and if you need key pair value that is in ...
Pradeep Kumar's user avatar
14 votes

How to update magento2 from 2.0.0 to 2.0.2

Just upgraded successfully to Magento 2.2.6 through composer: composer require magento/product-community-edition 2.2.6 --no-update Change the version accordingly e.g. 2.2.6 composer update rm -rf ...
Devtype's user avatar
  • 2,998
12 votes

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

You can display values from join two tables by using below model resource collection class function Add below function to your model resource collection function protected function _initSelect() ...
Suresh Chikani's user avatar
11 votes

json encode in magento 2

Nowadays, the recommended dependency to inject would be the \Magento\Framework\Serialize\SerializerInterface.
Jisse Reitsma's user avatar
9 votes

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

Response format (XML or JSON) is selected based on Accept header, set it to application/json on the client side.
Alex Paliarush's user avatar
9 votes

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

Add _initSelect method to Collection.php file in Vendorname\Modulename\Model\ResourceModel\Quote\collection.php With below code IMPORTANT: Please add addFilterToMap to initSelect Moethod Otherwise ...
Savoo's user avatar
  • 487
8 votes

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

use this one. public function suburbSearchAction() { /* Get Suburb text from POST Request */ $suburbNameQuery = $this->getRequest()->getParam('inputSuburbData'); /*...
Magento2 Devloper's user avatar
8 votes
Accepted

JSON request to controller giving error invalid form key

Try this Add form key in your form <input name="form_key" type="hidden" value="<?php echo $block->getFormKey();?>"> To get the controller url. $this->...
Hamendra Sunthwal's user avatar
7 votes

Unexpected end of JSON input after cache cleaned

I had this problem, and I identified that I had left some cms block with the field data-mage-init = { that is, without closing the tag } json
Bruno Monteiro's user avatar
6 votes

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

Magento 2 versions from 2.3 have a replacement for traditional install/upgrade schema which is used to maintain the database structure. From Magento 2 version 2.3, they have introduced the declarative ...
Gohil Rajesh's user avatar
  • 2,919
5 votes
Accepted

Magento2 : API Stock update

Using this documentation : Magento Commerce for B2B v2.2, I was able successfully create API calls for the stockItem. This is a PUT operation, make sure that you get the correct item_id for that ...
V Salvador's user avatar
4 votes

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

Use a cURL : $URL = curl_init( $www ); curl_setopt( $URL, CURLOPT_HEADER, 0 ); curl_setopt( $URL, CURLOPT_CUSTOMREQUEST, "GET" ); curl_setopt( $URL, CURLOPT_RETURNTRANSFER, true ); ...
Matt Silva's user avatar
4 votes
Accepted

How can i get image url with proper path?

Try this : $media = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $imageUrl = $media.'catalog/product/'. $product['image'];
Ashish Jagnani's user avatar
4 votes

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

Using the comments above, I've added the join to the Grid in a pretty simple and straightforward way. To have the joined tables, you cannot use Virtual type tables. So, that's how you make it happens ...
medina's user avatar
  • 580
4 votes

Convert model collection to json_encode

Try this: $result = $collections->toArray(); return json_encode($result); or $result = $collections->getData(); return json_encode($result);
Nero Phung's user avatar
  • 1,303
4 votes
Accepted

Magento 2: how to debug json error

The only JSON.parse command in main.js is in the getData function; specifically, at Line 52: 45 function getData(el) { 46 var data = el.getAttribute(dataAttr); ... 50 return { 51 el: el, 52 ...
Nathan Casebolt's user avatar
4 votes
Accepted

js-translation.json fails to generated

Use this command : Please set Vendor= Your vendor name and Theme= Your theme name for frontend php bin/magento setup:static-content:deploy --theme=Vendor/Theme en_US php bin/magento setup:static-...
Jugal Kishor's user avatar
  • 1,225
4 votes
Accepted

How to avoid using php://input?

Assuming $this->request is an instance of Magento\Framework\App\Request\Http, you can use the code below to get the JSON post body. $json = $this->request->getContent(); $data = json_decode($...
fmsthird's user avatar
  • 4,582
4 votes
Accepted

Magento 2 WebAPI json encode

Problem Summary: You have a PHP Array and you want to return it as a JSON Object. When you return your PHP Array, it gets converted to a JSON Array, which does not support non-sequential keys. So your ...
muhammedv's user avatar
  • 351
3 votes

How to update magento2 from 2.0.0 to 2.0.2

You can upgrade Magento 2 version via admin panel or from terminal area Upgrade : Admin Area Upgrade Navigate to System > Web Setup Wizard > System Upgrade Terminal Area Upgrade Before you start ...
Hung Tran's user avatar
  • 341
3 votes

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

I'd recommend using a light REST client over a browser. If you have chrome installed just install the "postman extension". There you can choose in which representation you want to see the answer.
Java_Waldi's user avatar
3 votes
Accepted

Magento 2: Intercept controller's JSON response

Class \Magento\Framework\Controller\Result\Json has two public methods for work with data. You can add plugin on their methods to modify json related data: class \MyVendor\MyModule\Controller\Result\...
KAndy's user avatar
  • 20.8k
3 votes

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

End your action with this. $this->getResponse()->setBody( Mage::helper('core')->jsonEncode(your data here) ); return;
Marius's user avatar
  • 198k
3 votes
Accepted

How to get json data on frontend controller in magento2?

You could use regular JSON response class: use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\App\ResponseInterface; class Test extends Action { ...
Siarhey Uchukhlebau's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible