-
Notifications
You must be signed in to change notification settings - Fork 7
/
psget
executable file
·51 lines (48 loc) · 1.5 KB
/
psget
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env php
<?php
require(__DIR__ . "/inc/common.php");
define("PSCMD","get");
try {
psGet::init($argv);
$args=PsGet::$args;
$object=array_shift($args);
psGet::readcfg(Array("global","get",$object));
$args=PsGet::$args;
array_shift($args);
if (count($args)<1) {
PsOut::error("Error! Enter object you want to get.\n".basename(__FILE__)
. " resource id [property]...\n"
. "Property '*' or empty properties means everything.\n"
. "Use --help to see available resources\n"
. "\n");
}
$objects=psCli::upobject($object);
$objectid = array_shift($args);
$properties = array_flip($args);
if (sizeof($properties)==0) {
psCli::$properties=Array("*" => 1);
} else {
psCli::$properties=$properties;
}
psCli::initApi();
$opt = array('resource' => $objects);
$opt['id'] = $objectid;
psOut::progress("Getting data for $objects($object)...");
$xml=psCli::apiCmd("get",$opt);
psOut::begin($object);
$rowdata=psGet::getValues($xml->children()->$object);
if (array_key_exists("*",psCli::$properties)) {
$rowdata2=$rowdata;
} else {
$rowdata2=Array();
foreach (psCli::$properties as $p=>$v) {
$rowdata2[$p]=$rowdata[$p];
}
}
psOut::write($rowdata2);
psOut::end($object);
} catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors
$trace = $e->getTrace();
PsOut::error('Other error<br />' . $e->getMessage());
}