PHP code example of gam6itko / ozon-seller

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

    

gam6itko / ozon-seller example snippets


use Gam6itko\OzonSeller\Service\V1\ProductService;
use Symfony\Component\HttpClient\Psr18Client;

$config = [$_SERVER['CLIENT_ID'], $_SERVER['API_KEY'], $_SERVER['API_URL']];
$client = new Psr18Client();
$svc = new ProductService($config, $client);
//do stuff

use Gam6itko\OzonSeller\Service\V1\CategoriesService;
use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
use Http\Factory\Guzzle\RequestFactory;
use Http\Factory\Guzzle\StreamFactory;

$config = [
    'clientId' => '<ozon seller client-id>',
    'apiKey' => '<ozon seller api-key>',
    // 'host' по умолчанию — https://api-seller.ozon.ru
];
$client = new GuzzleAdapter(new GuzzleClient());
$requestFactory = new RequestFactory();
$streamFactory = new StreamFactory();

$svc = new CategoriesService($config, $client, $requestFactory, $streamFactory);
//do stuff

use Gam6itko\OzonSeller\Enum\Language;
use Gam6itko\OzonSeller\Service\V1\DescriptionCategoryService;
use Symfony\Component\HttpClient\Psr18Client;

$config = [
    'clientId' => '<ozon seller client-id>',
    'apiKey'   => '<ozon seller api-key>',
];
$svc = new DescriptionCategoryService($config, new Psr18Client());

// дерево категорий и типов товаров
$tree = $svc->getCategoryTree(['language' => Language::RU]);

// характеристики конкретной пары «категория + тип»
$attributes = $svc->getCategoryAttributes(17028922, 91565, ['language' => Language::RU]);

// значения справочной характеристики
$values = $svc->getAttributeValues(17028922, 91565, 85, ['limit' => 100]);

use Gam6itko\OzonSeller\Service\V3\Posting\FbsService;
use Symfony\Component\HttpClient\Psr18Client;

$svc = new FbsService($config, new Psr18Client());

$result = $svc->list([
    'filter' => [
        'since'  => '2026-08-01T00:00:00.000Z',
        'to'     => '2026-08-08T00:00:00.000Z',
        'status' => 'awaiting_packaging',
    ],
    'limit' => 100,
]);

foreach ($result['postings'] as $posting) {
    echo $posting['posting_number'], PHP_EOL;
}

$posting = $svc->get('33920474-0032-1', ['analytics_data' => true]);

use Gam6itko\OzonSeller\Service\V3\ProductService;
use Symfony\Component\HttpClient\Psr18Client;

$config = [
    'clientId' => '<ozon seller client-id>',
    'apiKey'   => '<ozon seller api-key>',
    // 'host' по умолчанию — https://api-seller.ozon.ru
];
$svcProduct = new ProductService($config, new Psr18Client());

$product = [
    'offer_id'                => 'REDSGS9-512',
    'name'                    => 'Samsung Galaxy S9',
    'description_category_id' => 17028922,
    'type_id'                 => 91565,
    'barcode'                 => '8801643566784',
    'price'                   => '79990',
    'old_price'               => '89990',
    'currency_code'           => 'RUB',
    'vat'                     => '0',
    'height'                  => 77,
    'depth'                   => 11,
    'width'                   => 120,
    'dimension_unit'          => 'mm',
    'weight'                  => 120,
    'weight_unit'             => 'g',
    'primary_image'           => 'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555115.jpg',
    'images'                  => [
        'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555110.jpg',
        'https://ozon-st.cdn.ngenix.net/multimedia/c1200/1022555111.jpg',
    ],
    'attributes'              => [
        [
            'id'     => 8229,
            'values' => [['dictionary_value_id' => 971082156, 'value' => 'Смартфон']],
        ],
        [
            'id'     => 9048,
            'values' => [['value' => 'Samsung Galaxy S9']],
        ],
        [
            'id'     => 4742,
            'values' => [['value' => '512 ГБ']],
        ],
    ],
];

$res = $svcProduct->import($product);
// или пачкой (до 100 товаров за запрос)
$res = $svcProduct->import([$product, $product1, $product2]);
// или как в документации Ozon
$res = $svcProduct->import(['items' => [$product, $product1, $product2]]);

echo $res['task_id']; // сохраните, чтобы проверить результат через V1\ProductService::importInfo

use Gam6itko\OzonSeller\Service\V1\ProductService as V1ProductService;
use Gam6itko\OzonSeller\Service\V5\ProductService as V5ProductService;

// цены товаров: /v5/product/info/prices
$prices = (new V5ProductService($config, $client))->infoPrices(['visibility' => 'ALL'], '', 100);

// остатки по складам FBS: /v1/product/info/stocks-by-warehouse/fbs
$stocks = (new V1ProductService($config, $client))->infoStocksByWarehouseFbs(['sku' => [160249683]]);
shell script
php bin/is_realized.php | grep /v2/posting/fbs/get
shell script
php bin/is_realized.php path/to/swagger.json
php bin/is_realized.php --download
php bin/is_realized.php | grep NotRealized