PHP code example of beautinow / guanyicerp

1. Go to this page and download the library: Download beautinow/guanyicerp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

beautinow / guanyicerp example snippets


use beautinow\guanyicerp\guanyierp;

$config = [
    'appkey' =>  '[APPKEY]',
    'secret' =>  '[SECRET]',
    'sessionkey' =>  '[SESSIONKEY]'
];

$erp = new CErpApi($config);


$method='gy.erp.shop.get'; 
$data =[];
$filed ='shops';
$result = $erp->getTo($method, $data, $filed);


$error = $erp->error(); //出错信息,为否时表示无出错
$errno = $erp->error(true); //出错代号

$total = $erp->total; //条目总数,一般出现在请求列表
$orgi = $this->get('orgi'); //原始的返回内容


$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);

$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);

$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);

$data=[];
$data['page_no'] = 1;
$data['page_size'] = 1;
$data['item_code'] = 201495;
$data['warehouse_code'] = 110;
$result = $erp->getStock($data);

$result = $erp->getItemStock(201495,110);

$note = 'Test setItemStock for demo test';
$warehouse_code = 110;
$item_code = 201495;
$qry = 68;
$result = $erp->setItemStock($warehouse_code, $item_code, $qry, $note);


$note = 'Test setItemStock for demo test';
$warehouse_code = 110;
$items = [
    [
        'item_code' => 201497,
        'qty'   => 12
    ],
    [
        'item_code' => 201491,
        'qty'   => 33
    ]
];
$result = $erp->setItemStock($warehouse_code, $items, null, 'Test setItemStock for batch test');