Forums › Forums › Search & Filter Pro › Update Cache after WP All Import
- This topic has 12 replies, 3 voices, and was last updated 4 years, 9 months ago by
Ross.
-
Ross Moderator(Private) July 17, 2020 at 9:11 pm #253236
So it looks like on a cron job it fails?
That might make some sense actually… At least I finally have a line of investigation 🙂
Best
Ross Moderator(Private) July 27, 2020 at 11:55 am #253939Hi Scott
I’ve been doing some testing, but I still can’t replicate the issue.
I’ve setup wp-cron and told it to
wp_remote_get
the URLs provided for starting and processing (as described here):
https://www.wpallimport.com/documentation/recurring/cron/And I’m seeing the posts imported with all meta data… I’m thinking there could be a problem in your code.
I would enable
WP_DEBUG
, andWP_DEBUG_LOG
so you can write info when the cron job is run, to yourwp-content/debug.log
file – more info – https://stackoverflow.com/questions/24330039/how-can-i-use-error-log-with-wordpressThen use the
error_log()
function to write to that file and make sure you check it to see if your cron job is actually run…So I’m using this for my wp-cron setup (dumped in my child theme’s
functions.php
, you have to activate your theme again to register the event – ie, switch to another theme, and switch back):add_filter( 'cron_schedules', 'five_second_add_cron_interval' ); function five_second_add_cron_interval( $schedules ) { $schedules['five_seconds'] = array( 'interval' => 5, 'display' => esc_html__( 'Every Five Seconds' ), ); return $schedules; } // add schedule on theme activation add_action('after_switch_theme', 'sfdev_setup_options'); function sfdev_setup_options () { wp_schedule_event( time(), 'five_seconds', 'sfdev_cron_hook' ); } // remove schedule on theme deactivation add_action('switch_theme', 'sfdev_remove_setup_options'); function sfdev_remove_setup_options () { wp_clear_scheduled_hook( 'sfdev_cron_hook' ); } // add custom cron event add_action( 'sfdev_cron_hook', 'sfdev_cron_exec' ); function sfdev_cron_exec(){ error_log("CRON TEST"); // this will show up in wp-content/debug.log $remote_get = wp_remote_get( 'http://192.168.1.112:8319/wp-load.php?import_key=123456&import_id=4&action=trigger' ); $remote_get = wp_remote_get( 'http://192.168.1.112:8319/wp-load.php?import_key=-123456&import_id=4&action=processing' ); }
This triggers the import every 5 seconds (1 post imported only), and uses the URLs provided in wpallimport wp-admin for scheduling crons (you will need to get your own urls generated) – after testing with this, I repeatedly get the import event run correctly, and my search results updated correctly (S&F automatically sync’s the cache so no S&F code was added)
I would also advise, I just wrote the above for testing, I don’t think you are supposed to run both the
trigger
url andprocessing
url together in this way… but it suited my purposes for testing.Let me know your thoughts and please explain if you have a different setup that I can try to match.
Best
-
AuthorPosts