1. Knowledge Base
  2. HubSpot - PrestaShop

How to set up a CRON job

In order to run the initial sync and to have an automatic sync process from PrestaShop to HubSpot, we'd need to create a periodic process to call a PrestaShop URL

Step 1: Get the URL to make the call

In your PrestaShop account, scroll all the way down to the Hubspot section and click on  the dashboard link. You'll find the integration secure key at the bottom of the page, on blue: 

Hover over the link, right click on it and copy the address. It will look similar to this:

https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1

We'll use that URL to sync the data related to each object type.

Step 2: Create URLs for each object type.

We need to make 4 different calls (one for each object type) by using the URL gathered in the previous step.

We'll add a parameter to the string to target the correct objects (&object_type=object type to update):

  • Clients (CONTACT)
  • Products (PRODUCT)
  • Deals (DEAL)
  • Abandoned Carts (DEALABANDONED)

It is also possible to limit the number of objects to sync in each call by passing an additional parameter: &limit=number (recommended).

The four URLs will look as follows:

https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=CONTACT&limit=10

https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=PRODUCT&limit=10

https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=DEAL&limit=10

https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=DEALABANDONED&limit=10

 

Step 3: CRON Setup guide (Linux)

Below you can find a test crontab setup. Calls will be made every 5 minutes. It's advised to make sequential calls instead of running them concurrently to avoid performance issues

The execution order is as follows:

- Contacts

- Products

- Deals

- Abandoned carts

If it's not performed in this order, there could be references to objects that have not been synchronised yet, and that would create deals with missing information.

Create an executable file called sync.sh file and add the following content to the file (replace shopURL and secure_key, use your own):

#!/bin/bash
curl -s 'https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=CONTACT&limit=10'
curl -s 'https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=PRODUCT&limit=10'
curl -s 'https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=DEAL&limit=10'
curl -s 'https://shopURL.com/module/ps_hubspot/webhook?secure_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ajax=1&object_type=DEALABANDONED&limit=10'

Add this call to the crontab:

*/10 * * * * /PathToFile/sync.sh

This way calls will be done every 10 minutes and will sequentially sync 10 items for each type of object.

Please note: We advise running this sync.sh a couple of times to test how long it takes to complete the calls. It's essential that those calls are made sequentially and not at the same time as the website performance may suffer.

On Prestashop instances with heavy traffic or frequent product modifications, you might want to change how many products, contacts, or deals get synced on every call, or the frequency of the calls.

Now the sync progress will be visible at HubSpot Dashboard within PrestaShop.