How to connect PrestaShop to Stokis
Switch the webservice on under Advanced Parameters → Webservice, create a key with read access to the resources listed below, then paste the key into Stokis. There is no module to install, and it works on PrestaShop 1.7, 8 and 9.
What you need before you start
Stokis reads PrestaShop through the webservice that is part of every PrestaShop shop. You switch it on and create a key for Stokis in the back office. The pictures were taken on PrestaShop 8.2.8; on 1.7 and 9 the Webservice page sits under the same menu and has the same fields.
- A back office account that can open Advanced Parameters.
- A shop address that opens over https in a browser. Stokis connects over https only.
- URL rewriting on the server, which PrestaShop's webservice needs. Most shops have it on already.
- A Stokis account with a workspace that has no shop connected yet. One workspace holds one shop.
Switch the webservice on
In the back office open Advanced Parameters → Webservice. Under Configuration set Enable PrestaShop's webservice to Yes and press Save.
Create a key for Stokis
- Press Add new webservice key.
- Press Generate. PrestaShop fills in a key of 32 characters.
- Type a Key description that tells you later whose key it is, for example Stokis.
- Leave Enable webservice key on Yes.
Give the key read access to eleven resources
In the permissions table tick View (GET) and Fast view (HEAD) for these resources, then press Save: categories, combinations, configurations, currencies, manufacturers, order_details, orders, product_option_values, products, stock_availables, suppliers.
Do not tick customers or addresses. Stokis does not ask for them, and a key without them cannot read a customer's name, email or address.
Paste the key into Stokis
- Copy the key from the list on the Webservice page.
- In Stokis open Integrations and choose PrestaShop.
- Type the shop's address into Store URL. A trailing /api or slash is fine; Stokis strips it.
- Paste the key into API key.
- Press Test connection. Stokis checks every resource and names the ones the key cannot read.
- Press Connect. The first sync starts on its own and a dialog shows each step.
After the first sync Stokis reads the shop again on the schedule of your plan, and Sync now reads it on the spot.
Let Stokis add received orders to your stock
This step is optional. Tick Modify (PUT) for stock_availables on the key, and switch Push stock back to store on in the Integrations page of Stokis. Receiving a purchase order in Stokis then adds the received quantity to the product's stock in PrestaShop. Without that tick, or with the switch off, Stokis only reads.
A shop that uses Advanced Stock Management computes stock from its warehouses, so PrestaShop would overwrite the update. Stokis refuses the update for such a product; leave the switch off for that shop.
What Stokis reads from PrestaShop
| Stokis reads | Stokis uses it for |
|---|---|
| products, combinations, product_option_values | The product list. Each combination is its own product, named after its option values |
| stock_availables | Stock levels, stock cover and reorder points |
| orders, order_details | Sales history and the demand forecast |
| categories, manufacturers, suppliers | Filters and supplier links |
| currencies, configurations | The shop's currency, name and PrestaShop version |
The key decides what can be read. With only the eleven resources above ticked, nothing else in the shop is open to Stokis.
When PrestaShop does not connect
Stokis names what it found. Match the message you see.
| What you see | Cause | Fix |
|---|---|---|
| Invalid or expired API key | The key was copied in part, was deleted, or is switched off | Copy the key again from the Webservice page and check that it is enabled |
| Missing permissions on, followed by resource names | The key lacks View (GET) or Fast view (HEAD) on the resources named | Edit the key, tick both for each resource named, save, then test again |
| The PrestaShop webservice is disabled | Enable PrestaShop's webservice is set to No | Set it to Yes under Advanced Parameters → Webservice and save |
| Resource not found, check shop URL and resource name | The address is not the shop's, or URL rewriting is off on the server | Check the address, and switch URL rewriting on for the shop |
| PrestaShop returned non-JSON response | A firewall or security check in front of the shop answered in place of the webservice | Let Stokis through the firewall, then test again |
| The JSON webservice renderer raises a PHP warning | An old PrestaShop 1.7 release on a newer PHP answers every webservice request with an error | Exclude warnings from PHP error_reporting on the shop, or upgrade PrestaShop |
| Stokis connects over https. Check that your address opens in your browser | The shop has no working https address | Set up https for the shop, then test again |
How to replace the key or disconnect
- To stop Stokis reading the shop, open Advanced Parameters → Webservice and switch the key off, or delete it. It stops working at once.
- To replace the key, create a new one with the same permissions and paste it into the Integrations page in Stokis, then delete the old one.
- To disconnect on the Stokis side, press Disconnect in the Integrations page. The automatic sync stops and the saved key is removed. Your products and sales history in Stokis stay, and you can connect again later.
Questions about connecting PrestaShop
No. Stokis uses the webservice that is part of PrestaShop, with a key you create in the back office.
PrestaShop 1.7, 8 and 9. The pictures here were taken on 8.2.8; the Webservice page sits under the same menu and has the same fields on 1.7 and 9.
Test connection checks each resource with a HEAD request, which is quicker than reading it. PrestaShop treats that as its own permission.
No. The key has no access to the customers or addresses resources, so names, emails and addresses cannot be read.
Each combination is its own product in Stokis, because each one is ordered from the supplier separately.
Not unless you allow it. With Modify (PUT) on stock_availables and the push switched on in Stokis, the one thing it writes is a product's stock quantity when you receive a purchase order.