2015 was a big year for Magento as they released their next-generation platform: Magento 2. Some...
Cron jobs are necessary parts of Magento and they can handle all kinds of stuff where you need to take care of business in the background.
These jobs are a vital part of Magento and they are used to take care of functionalities in the background such as reindexing, sending emails, importing and exporting products and orders, etc.
Cron jobs aka scheduled operations are often used to handle integrations with 3rd party systems such as ERPs, CRMs or other data handlers. It is better to use crons than a manual action in the backend because:
My recommendation about cron jobs scheduling of M2 core parts is: if you don’t know what you are doing, leave it as it is. If you know what you are doing, you can tweak or even disable cron jobs that you know are of no use to you and would just take resources.
Schedules about importing products from ERP system can be client-specific but it is all about discussion why a client needs to have everything synced every 5 minutes. In case the ERP system is able to send only modified and new data the time frame can be smaller, but still, I would not advise anything below 1 hour because, after each import, the store needs to be reindexed so the data shows up on the frontend.
For full stock syncing, once per 24 hours is more than enough to get every data you need from the ERP.
With orders, it is a different story though. These you usually need to have in your ERP as soon as possible, especially when there are other actions linked to the order creation in ERP such as sending a special email to the customer about processing the order. I recommend having these running every 15 minutes so you can easily spot when there is a problem with the integration and orders are not coming through.
Bonus tip: make sure you have some sort of a visual aid to check which orders have been and have not been exported. The easiest one which does not involve any tampering with the sales order database is to create a comment that is not sent to the customer with order ID from the ERP. Another solution is to change the order status to something like Exported or store the ERP order ID in the existing external_order_id field for future reference and use.
Specific issues arise once some of the processes are manual and some are done via cron automatically. I have faced this on a M2.3 project where we had ERP integration to handle both order and product management.
The orders were automatically exported to the ERP every hour and sync of products was happening once per 24 hours. The issue became visible the next day the order was created once store manager wanted to ship this order and create label. All of a sudden we started to see an error message: “Not all of your products are available in this quantity.”
The problem was that even though the order was placed correctly and the stock was reserved, the import of products from ERP told us that there is 0 quantity and therefore cannot be sold or shipped.
The solution for this is to create another automated cron that would check orders placed and create shipment and labels for them automatically. This solved the issue but many questions appeared about multi source inventory (MSI) management and handling stocks outside of Magento
If you are interested in seeing the modules and extensions we are using for our SaaS Magento 2 platform, feel free to take a look at the Extension Page and get them for free!
On the other hand, if you are overwhelmed by maintaining your technology stack you should to check out our SaaS solution built on Magento 2. Focus on your customer, not technology.
Beecom is a funded startup and a collection of tech and e-commerce fanatics who’ve developed a best-in-class SaaS e-commerce solution for the European market. We are committed to building powerful tools for marketers who want to grow their e-commerce business while also providing a kick-ass user experience! Beecom is built on Magento 2 and ScandiPWA, meaning that you now have access to a robust and powerful platform that’s still somehow just as easy to use as Shopify!