PHP code example of mobly / buscape-sdk

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

    

mobly / buscape-sdk example snippets




obly\Buscape\Sdk\Client;
use Mobly\Buscape\Sdk\Collection\ProductCollection;

$collection = new ProductCollection();

// Maybe can be have more mandatory fields
$products = [
    [
        'sku' => 'AAA-123',
        'title' => 'Product Title One'
    ],
    [
        'sku' => 'AAA-123',
        'title' => 'Product Title Two'
    ]
];

foreach ($products as $product) {
    $collection->add($product);
}

$api = new Client([
    'app_token' => 'your_token',
    'auth_token' => 'your_auth_token',
]);

$response = $api->loadProducts($collection);

print_r($response);


$collection = new InventoryCollection();
foreach ($products as $product) {
    $buscapeProduct = new Inventory($product->toArray());
    $collection->add($buscapeProduct);
}

$api = new Client([
    'app_token' => 'your_token',
    'auth_token' => 'your_auth_token',
]);

$response = $api->inventoryUpdate($collection);

print_r($response);