lumnik. / scenarios All scenarios · Français

PrestaShop: the XML catalogue read in one line

Goal Read every product of a PrestaShop 8 shop through its Webservice, in XML, as it answers.

A real PrestaShop 8.2.8 and its demo catalogue. Its Webservice answers XML.

products.xml
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<products>
<product>
	<id><![CDATA[1]]></id>
	<reference><![CDATA[demo_1]]></reference>
	<price><![CDATA[23.900000]]></price>
	<name><language id="1" xlink:href="http://host.docker.internal:9320/api/languages/1"><![CDATA[Hummingbird printed t-shirt]]></language></name>
</product>
</products>
</prestashop>
manifests/10-products-xml.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata:  name: scenario-prestashop-a  connector_type: rest-generic  scopes: [catalogue]spec:  base_url: http://host.docker.internal:9320/webservice  auth: { kind: api-key, in: query, name: ws_key, value_env: SCENARIO_PRESTASHOP_A_KEY }  endpoints:    - id: products      path: /dispatcher.php?url=products&display=[id,reference,price,name]      method: GET      pagination: { kind: offset, offset_param: offset, limit_param: limit, limit: 5, response_path: $.products }      target:        kind: hybrid        table: ext.scenario_prestashop_a        unique_key: $.id        promote:          - { name: reference, path: $.reference, type: text }          - { name: price, path: $.price, type: text }
manifests/20-products-offset.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata:  name: scenario-prestashop-a  connector_type: rest-generic  scopes: [catalogue]spec:  base_url: http://host.docker.internal:9320/webservice  auth: { kind: api-key, in: query, name: ws_key, value_env: SCENARIO_PRESTASHOP_A_KEY }  endpoints:    - id: products      path: /dispatcher.php?url=products&display=[id,reference,price,name]      method: GET      response_format: xml                                # the shop answers XML      pagination: { kind: offset, offset_param: offset, limit_param: limit, limit: 5, response_path: $.products.product }      target:        kind: hybrid        table: ext.scenario_prestashop_a        unique_key: $.id        promote:          - { name: reference, path: $.reference, type: text }          - { name: price, path: $.price, type: decimal }          - { name: name, path: "$.name.language['#text']", type: text }
products.xml
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<products>
<product>
	<id><![CDATA[1]]></id>
	<reference><![CDATA[demo_1]]></reference>
	<price><![CDATA[23.900000]]></price>
	<name><language id="1" xlink:href="http://host.docker.internal:9320/api/languages/1"><![CDATA[Hummingbird printed t-shirt]]></language></name>
</product>
</products>
</prestashop>

Limits

  • An XML document that declares a DTD or an entity is refused: lumnik never reads one.
  • Values arrive as text: the price is promoted as decimal to compare it.
  • PrestaShop's demo catalogue: 19 products; a throwaway key, drawn at each replay.

E-commerce · catalogue

The catalogue lives in PrestaShop.

Every product must be read, every night.

PrestaShop 8.2.8, its demo catalogue

The problem

PrestaShop answers XML.

  • Not JSON, like most APIs.
  • And it pages its own way: limit=0,50.

What is not changed

The shop stays as it is.

  • Its Webservice, a read-only key.
  • No module, no setting.

The first try

The hub refuses XML it was not told about.

  • It never reads zero products in silence.
  • It says the word to add.

What had to be written

response_format: xml
pagination: { kind: prestashop }

Two lines.

  • 19 products out of 19, name and price.
  • A 25-line connector.

What was fixed

Three gaps found, three fixes.

  • The hub reads XML.
  • A repeated page fails the read.
  • The prestashop preset.

The limit

XML read safely.

  • No DTD, no entity: refused.
  • Values arrive as text.

Try it

The scenario replays locally.

Every step is published with its output.

This scenario runs on lumnik Open, free and open source.

Try lumnik Open →