Get Free Audit

Prestashop Web Services

Feb 10, 2014

8044 Alex Simonchik

Prestashop Web Services

Prestashop has an internal webservice which allows accessing a store from a remote application. Since the service is based on REST technology, this allows the remote applications to be cross-platform and use CRUD queries.

To start using the webservice you need to enable it first.  To switch on the  service go to Advanced Parameters -> Webservice:

1

Enable Active mode CGI for PHP if your server uses PHP not as an Apache module.

Next you need to create an Access Key, which you will have to specify when connecting the webservice to Prestashop. Each key gives access only to certain resources of the store. To generate a key go to Advanced Parameters -> Webservice -> Add New.

2

You will need to specify the key code, its description, status, configure access to the necessary system resources. You can also specify which CRUD requests will be available for each Prestashop resource (View, Mоdufy, Add, Delete, Fast view ). There is also an option to configure a multishop-association:

3

After querying this URL Prestashop will return an XML file with the list of all resources and all permitted CRUD operations for that resource for the specified Access Key.

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

4

An example of the response:

5

An example of the response:

6

The requests will work only if you allow the method GET for the resource Customer.

As shown in the table below, CRUD requests correspond to the type of an HTTP-request:

Comparison table of CRUD-requests and types of SQL queries.

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

To delete a resource entity use the following request pattern.

Fill out the XML with necessary data and send it back using the query.

All requests have a similar structure for each Prestashop resource. The main thing is that there should be access allowed to that resource and to CRUD operations for the key being used.

There is a ready-to-use PHP library written by Prestashop developers to work with the webservice. The library is available on Github. To use this library  you should install cURL on the server with a remote application.

You can find examples of usage here.

modules prestashop belvg

BelVG PrestaShop Store

Take your online store to the next level with PrestaShop modules by BelVG

Click to visit the store

Looking for a quality PrestaShop solution? Find a suitable one at BelVG store.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

22 Comments

  1. hi guys, hello from portugal :)
    i’m newer at prestashop, i’m trying to use web services from prestashop to comunicate with other api (PHC), but for now i’m trying with standard prestashop web service (backoffice) and i’m testing with chrome extension (POSTMAN)…and the results are:

    GET and DELETE are ok…
    But POST and PUT :( not…

    I have read and read a lot of information (google) but until now i’m not able to find something that works for me.
    Some help please!!!!

    Best regards,
    Rui

  2. Hi 2 all and thanks for the post. I’m trying to developing a new model to sync both prestashop sites using webservices but first step to do that is enable automatically webservices when my custom module is installed.

    Is there a way to do that?

  3. how to get the jsonformat data from webservice insted of xml format
    ?outputformat=json in url not working show a blank page

  4. Hi, this is a nice blog i have completed my application with prestashop restfull service i just need to place an order. with shiping and discount but it is giving error each time i place an order can u help me to place an order with rest full service.

  5. Hi,
    Can you please give us sample xml request to be send with the required parameters especially for creation and updation of products and orders?

  6. Thank you so much for the blog. It was more than useful for me.
    :)
    Short as well as sweet one.

  7. Great post, more easy than the Prestashop’s docs.

    Did you know how to erase products images? I’m trying it but I don’t have permission to delete it

    I’m working in a little script to remove duplicate images comparing all images of a product.

  8. hi denis,

    this is helpful and clear.

    1. i am just starting with prestashop and was wondering whether prestashop allows additional resources to be registered with the rest engine, so you can use it to access other resources than the ones in the default list. ( and of course in order to do so, what additional coding lies ahead )

    2. i would also be interested in creating json (bson) web services and use client side javascript to render stuff. it seems to me that performance wise this could be something. what are your thoughts on this?

  9. Hello:

    I have a prestashop running as a catalog, my problem is that I want to update the products stock via webservice. The webservice is provided by the supplier but I don’t know how to connect the WSDL from the supplier to my prestashop.

    Can you help me?

  10. I’m not getting the field in localhost/prestashop/api/customers/?schema=blank where can i find this?
    please can any one help on this?

  11. Great article, I however get an error when I try to view a specific order. Below is the error I get. When I turn debugging on it works fine. As soon as I turn it off the error returns. Any idea what it might be ?

    Internal error. To see this error please display the PHP errors.

  12. Xabi,

    You can find all the mandatory fields in the classes/Product.php you need to find $definition attribute there. All fields are listed there. If the field has a key “required” it means that the field is required.

  13. Hello,

    Nice article. You know how fields are required if I want create new product via REST service?

    Thanks,

  14. Hi,
    I am working on the 1.6 version and I have tried to enable REST webservice from localhost.
    when I visit this link
    http://localhost/myshop/api/
    I can’t get any xml .. the only page that I see is the 404 http_error.
    Have you any idea about that ?
    thanks in advance..

  15. Hi, I am trying to create order using prestashop 1.5.6.1 webservice. I could add customer, address, and cart but while creating order, it’s throwing error orderDetail->product_name is empty. Product is also not shown in cart and order. after adding order all amount values are shown zero. please suggest any workaround

  16. Juan,

    Try to activate ‘display_errors’ function in defines.inc.php, look what error you will get doing put request, and send it to us.

  17. Hi, Thanks for this post!
    I have a problem with web service in prestashop in order to update a product. I am using javascript to retrieve information and it works fine. I can insert new product with web service using javascript but I cannot update product. When I try it and I get the error 400 bad request doing PUT request.

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *