I want to fetch data from an ERP system and use that to fill the Woocommerce products. This operation is quite memory intensive and lengthy. So I'd like to run this through a cron that just calls a PHP file.

Can I 'just do that'? Or do I need to initialize the configuration file, the database, or anything else?

  • nothing prevents you running a WP CLI command on a cron job, it's even good practice to set up cron to run via WP CLI on a system cron job. What you do inside that CLI command though is up to you, and we can't help with WooCommerce development as 3rd party plugins are offtopic here. WP CLI can load the DB and APIs etc. There are lots of examples of how to write custom WP CLI commands in plugins on the official WP CLI docs site
    – Tom J Nowell
    Mar 13 at 13:39
  • 1
    I've dug into the WP-CLI cookbook, use the wp scaffold package and have created my own CLI command. Works like a charm, very nice stuff Apr 4 at 13:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.