Using the PrestaShop Web Service

Table of content

Using the PrestaShop Web Service

This tutorial demonstrates how to use the PrestaShop web service, using the dedicated PHP library to create a "CRUD" application.

Instead of using the tutorial, you can directly go read the Webservice one-page documentation.

Prerequisites

  • PrestaShop 1.5 installed on a server with mod_rewrite enabled (Apache only).

  • A local xAMP server with PHP5 enabled.

About CRUD & REST

The PrestaShop web service uses the REST architecture in order to be available on as many platforms as possible, since the HTTP protocol and XML files are understood by most platforms, if not all.

CRUD is an acronym that stands for "Create, Read, Update, and Delete". These are the four basic operations for managing data in an application.

REST defines roughly a style of software architecture, which promotes the use of HTTP methods when building web application, instead of custom methods or protocols such as SOAP or WSDL. It defines several rules, including one that is similar to CRUD, which is described below.

HTTP has several methods that can perform processing on data as defined in the REST architecture, among which are 4 main methods. See this page: http://en.wikipedia.org/wiki/HTTP#Request_methods

The table below offers a comparison with CRUD and SQL:

HTTP / REST

CRUD

SQL

POST

Create

INSERT

GET

Retrieve

SELECT

PUT

Update

UPDATE

DELETE

Delete

DELETE

About this tutorial

This tutorial explores how to create a small application to perform these four basic operations for customers.

Chapters 1, 2 and 3 are mandatory, as they contain the fundamental knowledge for using the web service.

The next chapters, explores ways to interact with the web service using each of the REST operations, in order to give you the tools to make a full CRUD application.

If you only want to retrieve data, for example when developing a web application to notify you of orders, you might only be interested in Chapter 4.

If you prefer to develop a more complete application, chapters 4 to 7 will interest you.

Chapters 9 and 10 give you more detail on specific content management.

Chapter 1 - Introduction: Creating Access to Back Office Chapter 2 - Discovery: Testing access to the web service with the browser Chapter 3 - First steps: Access the Web service and list client Chapter 4 - Retrieve Data: Retrieving a client Chapter 5 - Modification: Update client Chapter 6 - Creation: Remote Online Form Chapter 7 - Removal: Remove customer accounts from the database Chapter 8 - Advanced Use Chapter 9 - Image management Chapter 10 - Price management Cheat-sheet - Concepts outlined in this tutorial

Implementations

  • Manage your PrestaShop website through Open ERP: Prestashop OpenERP Connector by Akretion & CampToCamp (GNU Affero GPLv3)

  • A Scala library to access the PrestaShop web service: prestasac by Alex Dean (GNU Affero GPLv3)

  • A Python library to access the PrestaShop web service: prestapyt by Guewen Baconnier (GNU Affero GPLv3)

Files

Web service library

The latest version of the PSWebServiceLibrary.php file can be found on our code repository: https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/PSWebServiceLibrary.php To download the file:

  1. Copy/paste the file into an empty text local file, using for instance Notepad.

  2. Save the file as PSWebServiceLibrary.php

You can also directly download a zip archive of all the files in this repository, including the example files, by clicking here: https://github.com/PrestaShop/PrestaShop-webservice-lib/archive/master.zip

Examples files

All the example files can be found on our code repository: https://github.com/PrestaShop/PrestaShop-webservice-lib/tree/master/examples

Last updated