Skip to end of metadata
Go to start of metadata

An example of Using the PrestaShop Web Service using CRUD

This tutorial shows you how to use the PrestaShop web service with PHP library by creating a "CRUD" application.

Prerequisites

  • PrestaShop 1.4 installed on a server with mod_rewrite enabled (Apache only).
  • A local XAMPP server with PHP5.

About CRUD & REST

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

The PrestaShop web service uses the REST architecture in order to be available on as many platforms as possible, since HTTP and XML protocols are present on countless platforms.

REST defines an architecture that represents a set of good methods to practice on the web. It defines several rules, including one that we will describe that is similar to CRUD.

In HTTP, there are 4 main methods that can perform processing on data that are defined in the REST architecture. This correspondence can also be done with CRUD and SQL:

HTTP/ REST CRUD SQL
POST Create INSERT
GET Retrieve SELECT
PUT Update UPDATE
DELETE Delete DELETE

About this tutorial

Together, we will look at how to create a small application to perform these four operations on our customers.

Chapters 1, 2 and 3 are mandatory.

In the next chapters, you'll learn how to interact with the web service with each of the CRUD 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.

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 3.1 - Access the web service through the bookstore
Chapter 3.2 - Handling errors
Chapter 3.3 - List clients
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

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

Download the PDF Version of this tutorial.

A handy reminder of the concepts outlined in this tutorial, download the cheat-sheet.

Examples files

  Name Size Creator Creation Date Comment  
File 0-CustomersList.php 1 kB Anatole Korczak Jun 15, 2011 10:44    
File 1-Retrieve.php 2 kB Anatole Korczak Jun 15, 2011 10:44    
File 2-Update.php 3 kB Anatole Korczak Jun 15, 2011 10:44    
File 3-Create.php 3 kB Anatole Korczak Jun 15, 2011 10:44    
File 4-Delete.php 2 kB Anatole Korczak Jun 15, 2011 10:44    

Web service library

  Name Size Creator Creation Date Comment  
Show Old Versions File PSWebServiceLibrary.php 13 kB Anatole Korczak Dec 14, 2011 17:58    
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 25, 2011

    Anonymous says:

    i have just found the mistake in the example files first line in 0-CustomersList...

    i have just found the mistake in the example files
    first line in 0-CustomersList.php, 1-Retrieve.php, 2-Update.php, 3-Create.php, 4-Delete.php
    <html><head><title>CRUD Tutorial - Customer's list</head><body>
    so end tag of title is missing
    <html><head><title>CRUD Tutorial - Customer's list</title></head><body>
    please update the examples.zip package

    files should be renamed, 0- will be redirected because of htaccess settings, removing - would be better
    0CustomersList.php, 1Retrieve.php, 2Update.php, 3Create.php, 4Delete.php