PHP code example of priceva / priceva-sdk-php

1. Go to this page and download the library: Download priceva/priceva-sdk-php 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/ */

    

priceva / priceva-sdk-php example snippets


     // ...and other our files if it needed
    

use Priceva\PricevaAPI;


try{
    // or include our files directly, if you don't want to use Composer
      // error handler
}

try{
    // or include our files directly, if you don't want to use Composer
    Filters();
    $sources = new \Priceva\Params\Sources();

    $filters[ 'page' ]      = 1;
    $filters[ 'region_id' ] = 'a';

    $sources[ 'add' ]      = true;
    $sources[ 'add_term' ] = true;

    $products = $api->product_list($filters, $sources);
}catch( \Exception $e ){
    // error handler
}

try{
    // or include our files directly, if you don't want to use Composer
    Params\Filters();
    $product_fields = new \Priceva\Params\ProductFields();

    $filters[ 'page' ]      = 1;
    $filters[ 'region_id' ] = 'a';
    
    // we use 'flat model' of parameters here
    $product_fields[] = 'client_code';
    $product_fields[] = 'articul';

    $reports = $api->report_list($filters, $product_fields);
}catch( \Exception $e ){
    // error handler
}

$api = new PricevaAPI($api_key);

$filters        = new \Priceva\Params\Filters();
$product_fields = new \Priceva\Params\ProductFields();

$filters[ 'limit' ] = '1000'; // for example
$filters[ 'page' ]  = 1; // strong

... // some filters

$product_fields[] = 'client_code'; // if we need it field in answer
$product_fields[] = 'articul';  // if we need it field in answer

... // some product fields

$reports = $api->report_list($filters, $product_fields);

$pages_cnt = (int)$reports->get_result()->pagination->pages_cnt;

$priceva_products = $reports->get_result()->objects;

process_products($priceva_products); // client function for product processing

while( $pages_cnt > 1 ){
  $filters[ 'page' ] = $pages_cnt--;

  $reports = $api->report_list($filters, $product_fields);

  $priceva_products = $reports->get_result()->objects;

  process_products($priceva_products); // client function for product processing
}
`bash
php composer 
`
"priceva/priceva-sdk-php": "dev-master"