What is Cron, and how can it be utilised to streamline your Magento store

Preface

As a user, you might wonder what a cron is, and how you can make use of this in our new Magento app. Cron is a time based job scheduler meant to allow you to schedule tasks to run at specified times. This could be once a month, once a day, once an hour, or the first Sunday of every month, etc. You can utilise cron with our new connector to streamline your New Magento setup. This article won't go into how cron works exactly, but how to use it specifically with our Magento integration, I would urge you to check out the cron wiki here for learning more on the subject.


What form of cron do we use, and what does one look like?


There are two types of cron that surface if you look for information for it on the web. One includes seconds in it, and one doesn't (it only goes down to the minute). We use the second one as it's more standard in the industry. An example of how many characters a correct cron expression should have is below.

1 0 * * *

Note: Be sure to ask your Magento Host or Magento Developer during integration to make sure the cronjob service is running on the server.


So how does cron work with our new Magento integration?

You can find all the relevant configuration settings of the new Magento connector in Magento, under Interactions > Brightpearl > Configuration (With one exception we'll get to later).

These include:

  1. Import stock levels (bulk)
  2. Import prices
  3. Export order
  4. Export order status
  5. Export order payment
  6. Export skus

The one exception that can also be run on cron, but is not located here, is found under Interactions > Core > Configuration and is known as Log Cleaningmore on this later!

Depending on your server specifications, or more than likely, your needs as a business, you'll want to set up each of these functions to run automatically for you. You can click the links above if you're interested in finding out what each do, below I've prepared some common crons, and what use cases they fill!

Format: I will always include the explanation first, then a :, then the cron itself. A correct Cron should only look like: 0 0 * * *
An example of what you'll see below is:
Once every day at midnight: 0 0 * * *
Where '0 0 * * *' is the cron.

Note: You can use ANY of these crons on any interaction, though for some they will not make sense, or could cause issues (you don't want to run a bulk stock sync every minute for example).


Import stock levels (bulk)

The Import stock levels (bulk) cron lets you setup your full SKU list to have it's inventory updated from Brightpearl on a regular basis.

Recommended: 0 0 * * *

People often want to alleviate server load when running on smaller systems. This can be done by limiting the bulk sync of inventory to once a day, out of their hours: 0 0 * * *

For stores that do bulk uploads first thing, and want the stock to completely sync more often (on top of the Realtime Updates), you can schedule it to every twelve hours like this (Note: modify the number to change how often, but be sure it doesn't run more often than how long the bulk stock sync takes): 0 */12 * * *

What if your business receives inventory at a specific time each day? You can do this by replacing '0' here with the minutes of the hour of the time you want the sync to run, and '14' (2pm) with the hour of the time you want the sync to run. This runs a sync every day at 2pm:
0 14 * * *


Import Prices

The import prices cron allows you to schedule when your Magento prices update from the Brightpearl Price lists.

This is highly dependent on when you're importing new prices into Brightpearl, are you doing these daily? Monthly? Weekly? Here are a few common ones:

Import Prices the first of each month at midnight: 0 0 1 * *
Import Prices every other day at midnight: 0 0 */2 * *
Import Prices every Monday at 7AM: 0 7 * * MON


Export Orders

You often want the bulk order export to run fairly often, these in combination with having order created and order queued (Magento events which usually trigger when orders go through the creation process) will ensure your orders make it into Brightpearl if there isn't an issue with them.

Recommended:

Once an hour, every hour: 0 */1 * * *

Other configurations:
If you are having a flash sale or something similar, and are wanting to ensure every order is done as fast as possible, making this once every 30 minutes may make sense in some cases, but use this to your discretion: */30 * * * *


Export Order Status
This pushes order status updates (such as completed or cancelled) to Brightpearl. This can be important if someone cancels an order. The Events that exist will usually pick it up, but if they miss an order for whatever reason, this cron will pick up the order. For this we recommend running generally as often as your order import, but a bit after it's ran (25 after, you'll see why below!)

Recommended: 25 */1 * * *

Export Order Payments
Like the other interactions, you can have order payments download on events, when these events fail for whatever reason, this cron will pick things up. This will prevent delays in dispatching orders that are actually paid. We recommend to run this after the order export is ran, modify the 10 to 15/20 if you want a bit more timing in-between (in case yours takes longer to run).

Recommended: 10 */1 * * *

Export SKUs
The export SKUs functionality isn't completely vital to the integration itself. This is something that was built to allow you to see what products you had from Brightpearl (so you could not switch between systems). This is something that can be run once a night safely, and will update the 'Show Channel Availability' from Products > List Products. As such we recommend running this a few hours after your nightly stock sync.

Recommended: 0 2 * * *

Log Cleaning

This interaction cleans up the logs found in Interactions > Log. You should run this as often as you want to, as it will allow you to prevent your disk from filling with logs (in case of an issue, or a busy period). We recommend running this once each night, a few hours after your SKU export.

Recommended: 0 4 * * *

Wrapup

Cron is an essential tool to ensure your Magento website keeps Brightpearl up to date and vice versa. By properly configuring these you can pull the real power out of your Magento store and ensure you are always ready to process orders as fast as possible. Comment below with any Cron's you find useful!

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.