PHP code example of ashirchkov / ozon-sdk

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

    

ashirchkov / ozon-sdk example snippets

 php


use AlexeyShirchkov\Ozon\Seller\Client;
use AlexeyShirchkov\Ozon\Seller\ClientConfiguration;
use AlexeyShirchkov\Ozon\Common\Enum\VisibilityFilter;
use AlexeyShirchkov\Ozon\Common\Factory\SerializerFactory;
use AlexeyShirchkov\Ozon\Common\Exception\OzonApiException;
use AlexeyShirchkov\Ozon\Seller\V3\Model\Product\ListFilter;
use AlexeyShirchkov\Ozon\Seller\V3\Model\Product\ListRequest;

// PSR-18 HTTP client
$httpClient = new \GuzzleHttp\Client();
$configuration = new ClientConfiguration('https://api-seller.ozon.ru', 'client_id', 'api_key');
$serializer = SerializerFactory::createSymfonySerializer();

$ozonClient = new Client($httpClient, $configuration, $serializer);

try {

    $request = new ListRequest(
        filter: new ListFilter(
            visibility: VisibilityFilter::Visible
        ),
        limit: '100',
        last_id: 66245734
    );
    $response = $ozonClient->v3()->product()->list($request);

    echo $response->result->total;

} catch (OzonApiException $exception) {

    echo $exception->getMessage();

}