How to Set Up Cron Jobs for Global Inventory & Product Synchronisation

Modified on Tue, 14 Jan at 6:31 PM


How to Set Up Cron Jobs for Global Inventory & Product Synch


Global Inventory Synchronisation - Batches and log files

The batch handling has been much improved with batches processed at the rate of one/minute and progress is also shown for the Synch Now button.  Log files are generated for each batch and numbered sequentially for each batch along with a time stamp.  To avoid lots of clutter only the last 50 log files are kept.




The max batch size supported by the Xero API is 500, but they recommend it be set between 50 and 100 entries. We recommend that you try 500 to start with and if it does not show or synch all of the products reliably (by checking the log files) try reducing the batch size down to 200 then 100 etc.

This is how it works:

  • Depending on the number of products to be sent and the batch size, it will calculate the number of batches to be sent.
  • Cron jobs will be created to send each batch at the rate of one/minute.
  • After all the batches are sent, the process repeats depending on the user schedule selection: 5 minutes, hourly, daily.

 

 

Product Level Setting for Account Mapping

The accounts that product data maps into in Xero can be set at an overall level in the Xeroom settings General Tab or for granularity at the product level can be set in the Product data tab where Xeroom adds a new tab for Xero Account Settings.


Note Brands here is an example of Xero Category Tracking which can be up to two categories which can be used by Xero to tag products with useful labels such as brand, branch, channel etc.


 

*For detailed info on how to bulk load these settings see separate help article.

 

Global Product Synch Set Batch Size

The batching works exactly the same as in Global Inventory Synch.

 

Global Product Synch Log Files 

As with the Global Inventory Synch the log filenames have been shortened and a batch number suffix added to each one for each run so it is easy to check that the synch is happening correctly and for all batches.

 

The Product Synch log file shows what the new values that have been changed to are for each product and also if unchanged will state that:

 

 

 


Inventory and Product Synch - Cron Job Troubleshooting


Xeroom uses the cron job system in WordPress to perform the synchronisations.  Xeroom now enables you to test that it is working and log files are created, which show under the Xeroom/log files menu item.  If these are not there and the batches are not running or running at weird intervals then check your cron system and if necessary, disable your WordPress cron and enable a server based cron to run ideally every minute (but beware of large jobs that your system runs such as Updraft backups that won’t complete in a min and can lead to starving the resources so do fully test).  

For scheduled synchs running under cron the batches are processed at the same rate as the cron time interval, eg if cron is set to run every 5 mins and synch is hourly with say 3 batches then it will run the first batch each hour, then 5 mins later the next batch and so on.   

You can install a cron manager or scheduling plugin, there are lots and WP Control is a good one that shows both events and schedules.

For further info please see https://developer.wordpress.org/plugins/cron/ and https://www.wpeditorial.com/how-and-why-to-use-the-server-cron-instead-of-wp-cron/.

Q:  Can you send me the cron line to call the function: xeroom_sync_schedule?

A: https://wpspeedmatters.com/external-cron-jobs-in-wordpress/ Gives can find a detailed way to setup and achieve a 3rd party cron job on WordPress. Here is a short resume:

  • first, disable define('DISABLE_WP_CRON', true);
  • after that, go to the hosting dashboard cron job, create a new cron that executes every 1 or 2 minutes and add the URL wget -q -O - https://www.yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

The xeroom_sync_schedule is only available if something is in a queue to be synched with Xero. If not, the xeroom_sync_schedule cron will be removed. That's why you should implement the 3rd party cron jobs as above.


Better Host Cron Job Management


Some of the better hosts provide WordPress cron management solutions eg Cloudways offer the below.  Ask your host if they offer this if you are not IT competent.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article