Adjusting imports to work with Super Speedy Filters

Super Speedy Filters maintains side-tables that copies the contents of wp_posts, wp_postmeta and wp_term_relationships into another table – fww_object_ancestors – so the data can be queried in a more efficient manner. This more efficient manner makes it far easier to create SQL queries that run quickly.

Automatic table maintenance

By default these tables are automatically maintained, but you may be taking advantage of various import tools options to disable do_action calls. If you disable do_action calls then there are a couple of functions you should call when your imports are complete in order to keep everything in sync.

If your tables end up out of sync, you can force a rebuild from the Settings > Super Speedy Filters > Advanced tab, but it’s best to avoid this requirement by updating your import jobs to work with Super Speedy Filters.

If you wish to take advantage of our automatic table maintenance, we recommend you do not use the option in WP All Import (or other import tools) to disable the do_action calls. If you keep the do_action calls, you never need to call any functions manually.

Manual functions to maintain fww_object_ancestors

Our fww_object_ancestors table works so fast because it solves the queries in advanced to determine which posts are children of the current term.

There are two functions you can call to keep this table in sync:

ssf_update_object_ancestors_post($post_id);

You can pass the $post_id to the above function and fww_object_ancestors will be updated for all terms relating to this post.

ssf_create_ancestors_table_contents();

The above function should be used to rebuild the entire table. This can be useful if you are running significantly large imports and then you can run a single update at the end of the entire import.

If you make a call to fww_ajax_recalc_terms it performs an asynchronous request to rebuild the entire table. This asynchronous aspect means the function will return quickly having added all of the items required to rebuild the table to a queue. The table will then continue to be built in the background. This is necessary because of the length of time that rebuilding the entire fww_object_ancestors table can take – if you have 300,000 products, this process will probably take about 5 minutes to complete.

Example code for WP All Import

If you are using WP All Import, and you make use of their option to disable do_action calls, then you should call our table maintenance function after your imports are complete – or nightly is also an option.

With WP All Import, there are a variety of action hooks – the one we need is pmxi_after_xml_import.

add_action( 'pmxi_after_xml_import', 'rebuild_ssf_table', 10, 2 );
function rebuild_ssf_table($import_id, $import) {
if ($import_id == 1) {
ssf_create_ancestors_table_contents();
}
}

Summary

If you do not disable do_action calls in your imports, then you do not need to adjust your imports. Otherwise, there is one function you can call to rebuild the entire table and another function you can call on a per-post basis.

If you are using another import tool, adjust your code accordingly, or come ask for help in our Discord channels.

Be the first to comment and we'll reply right away.

Leave a reply

Super Speedy Plugins
Logo