rem42 / scraper-prestashop
API Prestashop 1.7
Installs: 1 506
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 3
Requires
- php: ^8.1
- ext-json: *
- rem42/scraper: ^3.2
Requires (Dev)
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^9.6
- rem42/php-cs-fixer-config: ^3.6
This package is auto-updated.
Last update: 2024-10-05 13:42:21 UTC
README
Scraper can handle multiple request type and transform them into object in order to create some API.
Installation
composer require rem42/scraper-prestashop
Requirement
- PHP >= 8.1
Usage
Initiate the client with the http client of your choice that implement the Symfony\Contracts\HttpClient\HttpClientInterface
interface.
<?php use Scraper\Scraper\Client; use Symfony\Component\HttpClient\CurlHttpClient; use Symfony\Component\HttpClient\NativeHttpClient; $client = new Client( new CurlHttpClient() // OR new NativeHttpClient() );
Then you can use the client to make request to the API.
Product list
<?php 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
Product detail
<?php 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