Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

49

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 php bin/magento cache:flush php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento indexer:reindex php bin/magento maintenance:disable ...


20

Just try with return $this->resultJsonFactory->create()->setData(['Test-Message' => $message]) instead of: $result = $this->resultJsonFactory->create(); $result->setData(['Test-Message' => $message]); return $result; Note: on __construct function, You need to add jsonFactory class protected $resultJsonFactory; public ...


19

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 crons enabled or it will not work. Make sure in configuration you have your keys inserted. If it freezes with no output in the logs you can check the php logs ...


15

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 var/di var/generation/* var/view_preprocessed/* var/cache/* var/page_cache *// The issue following commands one by one chown -R user:group . chmod u+x bin/...


12

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 response should have key and value as like /rest/V1/categories we need to create data interface To test in Chrome download plugin called rest client app call ...


9

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/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld RH_Helloworld is module name. If no module name is specified, then the default ...


8

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() { parent::_initSelect(); $this->getSelect()->joinLeft( ['secondTable' => $this->getTable('tablename')], ...


6

Response format (XML or JSON) is selected based on Accept header, set it to application/json on the client side.


5

use this one. public function suburbSearchAction() { /* Get Suburb text from POST Request */ $suburbNameQuery = $this->getRequest()->getParam('inputSuburbData'); /* Retrieve RAM Model at: Webtonic/Ram/Model/Shipping/Carrier/Ram.php */ $model = Mage::getModel('ram/shipping_carrier_ram'); Mage::register('...


5

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 removed in a future version when the install/upgrade script be no longer supported. In the current dual state where tables and columns can be added/altered/...


4

I think the problem in your case is not the code. It's the browser. You can read more about it here. And here is a simple test you can run in the console. var a = {1:'a', 3:'b', 2: 'c'}; console.log(a); the result will be (at least on chrome and FF): Object { 1="a", 2="c", 3="b"} I was able to overcome this with the following trick. In js/...


4

We currently have an observer that sends our order data to our Oracle DB. It observes checkout_onepage_controller_success_action and the code formats the order into JSON and transmits it via a web service to our Oracle DB. We are using 1.0.4.1 so I'm not sure if it would work with your version. Anyway, here is a skeleton of it, I took out the meat ;-) This ...


3

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 ); curl_setopt( $URL, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Authorization: Bearer " . $token_API ) ); In ...


3

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.


3

The event will depend of the moment that you would like to send the order to supplier. If is when the order is placed the best is sales_place_order_after. If is when the order is paid them you can use sales_order_payment_pay. The sales_order_payment_pay is dispatched after each invoice is paid and updates the totals of payment. So you can check the ...


3

It is not good idea to return a php object to json value.As per as,php concept json is convert a string varible and an array of string variables to json object. Json does not capable to convert a php to json object. If you want data then need to return customer data in array format. just like: $jsonData = Mage::helper('core')->jsonEncode($customer-...


3

I'm not sure what you are exactly talking about. Where in magento, registration or checkout? But I'll try. The regions are ordered by name by default: \Mage_Directory_Model_Resource_Region_Collection::_construct protected function _construct() { $this->_init('directory/region'); $this->_countryTable = $this->getTable('directory/country'...


3

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 please apply the MDVA-532 patch, open your terminal and enter this: composer require magento/product-community-edition 2.1.0 --no-update composer update Next ...


3

End your action with this. $this->getResponse()->setBody( Mage::helper('core')->jsonEncode(your data here) ); return;


3

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 { /** * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; public function __construct( ...


3

Serializing the object will most likely serialize the entire PHP Object. That's the reason why you end up with a massive file. You only want to log the payload from that request. I've wrote a module once that would log all API requests to the database for debugging purposes. The way I did it was with a plugin around the dispatch()-method of \Magento\Webapi\...


3

Use jsonDecode() function of helper Magento\Framework\Json\Helper\Data protected $jsonHelper; public function __construct(\Magento\Framework\Json\Helper\Data $jsonHelper) { $this->jsonHelper = $jsonHelper; } public function decodeSomething($jsonData) { return $this->jsonHelper->jsonDecode($jsonData); }


3

Check like that in your json you will get $_product->getCategoryIds(). Please write a condition like that <?php foreach ($temp as $product): ?> if (in_array($currcategory , $_product->getCategoryIds()) { Hope it will helpful for you


3

You can try in your ajax success response like below, .done(function(data) { var priceValue = data.price_component; console.log(data.price_component); });


3

Try this: $result = $collections->toArray(); return json_encode($result); or $result = $collections->getData(); return json_encode($result);


3

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-content:deploy --theme=Vendor/Theme fr_FR I had problem in admin panel and I ran php bin/magento setup:static-content:deploy --theme=Magento/backend en_US php ...


3

If I understand you correct you are posting json in the body Therefore have you tried this $this->getRequest()->getContent() Eg https://github.com/magento/magento2/blob/ddf42caaf25311f10b23b95a92746f99943e045e/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php#L56


3

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 keys get ignored and you end up with a sequential array of your values. Solution Summary: You need to return a PHP Object in order to have a JSON Object in ...


2

Another method I found and worked like a charm. $this->getResponse()->clearHeaders()->setHeader('content-type', 'application/json', true); $this->getResponse()->setBody(json_encode($array));


2

jsonEncode ends up using Zend_Json_Encoder here you will find a function _encodeValue which will either return an array or a object depending on the type of value. protected function _encodeValue(&$value) { if (is_object($value)) { return $this->_encodeObject($value); } else if (is_array($value)) { return $this->...


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