WebService API
AnswerKit adds two resources to the PrestaShop WebService API. A PIM, an ERP or a simple script can then create and maintain your FAQs, the way it already does for products.
| Resource | Content |
|---|---|
answerkit_items | The questions: active, and question and answer in each language |
answerkit_links | Where each question shows: id_item, type, id_object, position |
Give rights to a key
- Advanced Parameters > Webservice: check that the webservice is enabled.
- Create a key (or edit yours) and tick the rights you need (GET, POST, PUT, DELETE) on answerkit_items and answerkit_links.
- Save.
When the module is uninstalled, these rights are removed from every key.
Create a question
POST /api/answerkit_items
<prestashop>
<answerkit_item>
<active>1</active>
<question>
<language id="1">How do I choose my size?</language>
<language id="2">Comment choisir ma taille ?</language>
</question>
<answer>
<language id="1"><![CDATA[<p>Take your usual size.</p>]]></language>
<language id="2"><![CDATA[<p>Prenez votre taille habituelle.</p>]]></language>
</answer>
</answerkit_item>
</prestashop>
Language ids are the ones of your shop (International > Localization > Languages). The response returns
the id of the new question.
Show it on a page
POST /api/answerkit_links
<prestashop>
<answerkit_link>
<id_item>42</id_item>
<type>product</type>
<id_object>12</id_object>
<position>0</position>
</answerkit_link>
</prestashop>
type | id_object |
|---|---|
product | product id |
category | category id |
manufacturer | brand id |
cms | CMS page id |
home | 0 (home page) |
all | 0 (all products) |
position sets the order on the page (lowest first). A link to a question, product, category, brand or page
that does not exist is refused with a clear message.
Read, update, delete
As for any PrestaShop resource:
GET /api/answerkit_items?display=full: every question;GET /api/answerkit_links?filter[type]=product&filter[id_object]=12&display=full: the questions of a product;PUT /api/answerkit_items/42: update a question;DELETE /api/answerkit_items/42: delete a question and all its links;DELETE /api/answerkit_links/7: remove the question from one page, without deleting it.
What the module does on every write
- Answers go through the same cleaning as the back office: a forbidden tag is removed, not refused;
javascript:anddata:links are blocked. - The FAQ cache is cleared: the shop shows the new version at once.
- Fill in at least the default language: it is the one the back office shows. On the shop, each language only shows the questions that have a question and an answer in it.