PHP code example of rem42 / scraper-prestashop

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

    

rem42 / scraper-prestashop example snippets




use Scraper\Scraper\Client;
use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Component\HttpClient\NativeHttpClient;

$client = new Client(
    new CurlHttpClient()
    // OR
    new NativeHttpClient()
);



use Scraper\ScraperPrestashop\Request\PrestashopGetRequest;
use Scraper\ScraperPrestashop\Entity\PrestashopProducts;

$request = new PrestashopGetRequest(
    'host.com', // Your prestashop host
    'key', // Your prestashop webservice key
    'products', // The resource you want to get, like 'products'
);

// optional for list request
$request
    ->addFilter('limit', 1)
    ->addFilter('offset', 1)
;

/** @var PrestashopProducts $products */
$products = $client->execute($request);

$products->getProducts(); // Return an array of PrestashopProduct



use Scraper\ScraperPrestashop\Request\PrestashopGetRequest;
use Scraper\ScraperPrestashop\Entity\PrestashopProduct;

$request = new PrestashopGetRequest(
    'host.com', // Your prestashop host
    'key', // Your prestashop webservice key
    'products', // The resource you want to get, like 'products'
);

$request->setId(42);

/** @var PrestashopProduct $product */
$product = $client->execute($request);

$product->name; // Return the product name
$product->dateAdd; // Return the product creation date