Sync Markers



A syncMarker will help you to create an efficient and fast synchronization process.
They are available for the following items:

  • Products & Articles
  • Relations
  • Orders
  • Invoices
  • Receipts

Let’s imagine that you want to build an application that synchronizes all invoices from Mplus to another system.
You could simply retrieve all invoices everytime you do a synchronization, but that will severely impact performance as more and more invoices are added to the system.
A smarter idea would be filtering invoices by date using the fromFinancialDate and throughFinancialDate parameters.
But what if an invoice is changed in Mplus after you have already processed the date of that invoice?
The best way to solve that problem and properly implement synchronization is using the syncMarker parameter.

How the syncMarker works

The syncMarker is a continuous sequence of integers that is raised by one everytime an item is changed, regardless of the initial creation date of the item. The syncMarker is passed along as an additional parameter when the item is retrieved through the API. Each type of item listed above has their own sequence of integers.

You should save an internal value of the syncMarker to use in your synchronization.
When you perform synchronization for the first time, your internal syncMarker should typically be set to a value of 1. That way you start from the beginning.

Let’s assume this call retrieved the following invoices:

Because the highest value of syncMarker in these results is 4, you save that value of 4 as your internal syncMarker.

When the next invoice is added or changed in Mplus, that invoice will get a syncMarker value of 5. The next time you perform the synchronization, you use your own internal syncMarker value of 4, you add 1 to that before you do the request, and you will only receive this next invoice in the results, because it has a syncMarker value of 5.

This time around you save the value of 5 to your internal syncMarker. Everytime you synchronize you repeat this process.

getCurrentSyncMarkers Retrieves list of all syncMarkers

This function shows the highest syncMarker of each type.

If successful, the variable $syncmarkers which we set in the example can have the following contents: