Pobo SDK is a PHP library designed to integrate with the Pobo system. It provides functionality for bulk uploading products, retrieving all products, and fetching categories.
composer require pobo-builder/pobo-php-sdk
try {
$user = new \Pobo\UserClient(
'email',
'password'
);
} catch (\Pobo\Exceptions\AuthenticationException $e) {
echo 'Authentication failed: ' . $e->getMessage();
}
$client = new \Pobo\PoboClient($user);
Retrieve a list of all categories from the system:
/**
* @var \Pobo\Libs\Models\CategoryModel[] $categories
* @throws \Pobo\Exceptions\ApiClientException
*/
$categories = $client->categories()->list();
foreach ($categories as $category) {
echo $category->getName();
}
Retrieve a specific category by its ID.
/**
* @var \Pobo\Libs\Models\CategoryModel $category
* @throws \Pobo\Exceptions\ApiClientException
*/
$category = $client->categories()->getById(300869);
echo $category->getName();
Retrieve a specific category by its GUID.
/**
* @var \Pobo\Libs\Models\CategoryModel $category
* @throws \Pobo\Exceptions\ApiClientException
*/
$category = $client->categories()->getByGuid('1d7dc679-f76e-11ed-82e5-ce12b750376e');
echo $category->getName();
Retrieve a specific category by its name.
/**
* @var \Pobo\Libs\Models\CategoryModel $category
* @throws \Pobo\Exceptions\ApiClientException
*/
$category = $client->categories()->getByName('Category Name');
echo $category->getName();
Add a new category to the system. This function returns the created CategoryModel.
/**
* @var \Pobo\Libs\Models\CategoryModel $category
* @throws \Pobo\Exceptions\ApiClientException
*/
$category = $client->categories()->add(
'New Category',
'https://pobo.myshoptet.com/new-category/',
'885a0720-1dde-11ee-9ccb-c23895735dfd',
);
echo $newCategory->getId();
Retrieve a list of all products from the system:
/**
* @var \Pobo\Libs\Models\ProductModel[] $products
* @throws \Pobo\Exceptions\ApiClientException
*/
$products = $client->products()->list();
foreach ($products as $product) {
echo $product->getName();
}
Bulk upload multiple products to the system:
$categoryIds = [
1,
2,
3
];
### OR ###
$categoryIds = [
$client->categories()->getById(300869)->getId(),
$client->categories()->getByGuid('1d7dc679-f76e-11ed-82e5-ce12b750376e')->getId(),
$client->categories()->getByName('iPhone')->getId(),
$client->categories()->add('Nová kategorie', 'https://pobo.myshoptet.com/nova-kategorie/', '885a0720-1dde-11ee-9ccb-c23895735dfd')->getId(),
];
$bulkImport = $client->products()->bulkImport(
[
[
'guid' => '302b8ad6-07d5-11ec-b98c-0cc47a6c9370',
'name' => 'Test Product from API',
'short_description' => 'This is a test product created via API.',
'description' => '<p>HTML description of the product.</p>',
'is_visible' => true,
'categories' => $categoryIds,
'images' => [
[
'src' => 'https://picsum.photos/200/300',
],
[
'src' => 'https://picsum.photos/200/300',
'main_image' => true,
],
]
]
]
);
print_r($bulkImport);
Array
(
[result] => Array
(
[success] => 1
[skipped] => 0
[errors] => Array()
)
)