PHP wrapper for Prestashop web service
-
Clone this repository in your new working directory.
-
Download the
composer.phar
executable or use the installer.curl -s https://getcomposer.org/installer | php
-
Run Composer:
php composer.phar update
// initialize WebService
$webservice = new PrestashopWebservice\Webservice('http://mystore.com/', 'your-prestashop-api-key', false);
// initialize CacheProvider (optional)
$cache = new Doctrine\Common\Cache\PhpFileCache(__DIR__.'/cache');
$webservice->setCacheProvider($cache);
$webservice->setTtl(60);
// initialize Logger with Monolog (optional)
$logger = new Monolog\Logger('prestashop');
$handler = new Monolog\Handler\StreamHandler(__DIR__.'/logs/prestashop.log');
$logger->pushHandler($handler);
$webservice->setLogger($logger);
$products = $webservice->getProducts();
echo '<ul>';
foreach ($products as $product) {
echo '<li>' . $product->id . ' - ' . $product->name[1] . '</li>';
}
echo '</ul>';