PHP code example of josalba / prestashop-webservice-lib

1. Go to this page and download the library: Download josalba/prestashop-webservice-lib 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/ */

    

josalba / prestashop-webservice-lib example snippets


use prestashop\prestashopWebserviceLib\StockAvailables\Application\Get;
use prestashop\prestashopWebserviceLib\Shared\Domain\Display\DisplayFull;
use prestashop\prestashopWebserviceLib\StockAvailables\Domain\Filter;

$get = new Get('https://tu-tienda.com/api/', 'TU_TOKEN_API');
$display = new DisplayFull();
$filter = new Filter(id: '1');

$result = $get($display, $filter);
// $result es una instancia de PrestashopStockAvailable

use prestashop\prestashopWebserviceLib\Categories\Application\Get;
use prestashop\prestashopWebserviceLib\Categories\Domain\Display;

$get = new Get('https://tu-tienda.com/api/', 'TU_TOKEN_API');
$display = new Display(id: true, name: true, active: true);

$result = $get($display);
// $result es una instancia de PrestashopCategory

use prestashop\prestashopWebserviceLib\StockAvailables\Application\Put;
use prestashop\prestashopWebserviceLib\StockAvailables\Domain\StockAvailable;
use prestashop\prestashopWebserviceLib\StockAvailables\Domain\PrestashopStockAvailableUpdate;
use prestashop\prestashopWebserviceLib\Shared\Domain\ShopParam;

$put = new Put('url','token');
$item = new PrestashopStockAvailableUpdate([new StockAvailable(id: 1, quantity: 10)]);
$shopParam = new ShopParam(shopId: 1); 

$result = $put($item, null, $shopParam);