Skip to content

Commit a9bd1bc

Browse files
committed
Add optional JSON response format
1 parent b9323fd commit a9bd1bc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

PSWebServiceLibrary.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public function add($options)
358358
*
359359
* @param array $options Array representing resource to get.
360360
*
361-
* @return SimpleXMLElement status_code, response
361+
* @return SimpleXMLElement|string status_code, response
362362
* @throws PrestaShopWebserviceException
363363
*/
364364
public function get($options)
@@ -372,7 +372,7 @@ public function get($options)
372372
$url .= '/' . $options['id'];
373373
}
374374

375-
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'schema', 'language', 'date', 'price');
375+
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'schema', 'language', 'date', 'price', 'output_format');
376376
foreach ($params as $p) {
377377
foreach ($options as $k => $o) {
378378
if (strpos($k, $p) !== false) {
@@ -391,6 +391,10 @@ public function get($options)
391391

392392
$this->checkStatusCode($request);// check the response validity
393393

394+
if (isset($options['output_format']) && $options['output_format'] === 'JSON') {
395+
return $request['response'];
396+
}
397+
394398
return $this->parseXML($request['response']);
395399
}
396400

0 commit comments

Comments
 (0)