Orders Export to Third-Party Systems in Prestashop

Orders Export to Third-Party Systems in Prestashop

A lot of online retails often need to export orders to third-party systems and services. They do it for inventory accounting, store houses, sales reports etc.  There are plenty of such systems, and each of them has its own data transfer format. Despite the fact, that there are a lot of export modules on Prestashop Addons Marketplace, sometimes they are not appropriate, because each service has its own file format, its limitations, etc. So, that’s why there is a need to write your own script exports. Let’s consider the most popular file format: XML.

As an order is a set of several entities (the order itself, the customer, address, products, payment information, delivery, etc. ) we should configure the list of properties, which we are going to export.

To do this, we will create a special array of properties for each entity:

For every entity you should prescribe necessary properties, which can be seen in every class of their array. All array classes are located in the folder /clases/

Then we create a method, which generates an xml string for set of properties:

To get an array of orders, you should register a simple query:

However, it is  sometimes necessary to export not all orders in the store, but only the latest ones. Therefore we will export the last 100 orders:

Now we proceed to the formation of XML-document:

Then we should register titles to generate the file and send it to download:

All set, the file has been generated and downloaded.



1 comment

Post a new comment

top