Reply To: Products not loading
Hi Sarah,
I was able to troubleshoot this, and discovered that it’s a combination of the size of the response, and Cloudflare’s timeout limit. Since your site contains so many products, our request to retrieve those products results in a very large query and response data. This results in your server taking a long time to return the data. However, Cloudflare sets a timeout of 100 seconds for requests (their Enterprise plans allow for 600 seconds). The request is exceeding this time limit, so the Catalog Builder is never receiving your products.
One solution would be to cache these requests, so the data is returned much quicker. There’s a free plugin you can use to do this.
1. Install and activate this plugin: WP REST Cache. Installation instructions are found on the plugin page at that link.
2. Add the code below to your functions.php file.
3. If you prefer, I can set this up for you. I’d need some temporary administrator login credentials to do it, though, so you can paste those details here in the ticket.
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_wc_endpoints', 10 ); /** * Register the WooCommerce endpoints so they will be cached. */ function wprc_add_wc_endpoints( $allowed_endpoints ) { if ( ! isset( $allowed_endpoints[ 'wc/v3' ] ) || ! in_array( 'products', $allowed_endpoints[ 'wc/v3' ] ) ) { $allowed_endpoints[ 'wc/v3' ][] = 'products'; } return $allowed_endpoints; } add_filter( 'wp_rest_cache/cacheable_request_headers', 'wprc_add_cacheable_request_headers', 10 ); function wprc_add_cacheable_request_headers( $cacheable_headers ) { $cacheable_headers['wc/v3/products'] = 'authorization'; return $cacheable_headers; } add_filter( 'wp_rest_cache/determine_object_type', 'wc_determine_object_type', 10, 4 ); function wc_determine_object_type( $type, $cache_key, $data, $uri ) { if ( '/wp-json/wc/v3/products' === substr( $uri, 0, 23 ) ) { return 'product'; } return $type; } add_action( 'created_product_cat', 'wc_flush_category_caches', 10 ); add_action( 'edit_product_cat', 'wc_flush_category_caches', 10 ); add_action( 'delete_product_cat', 'wc_flush_category_caches', 10 ); function wc_flush_category_caches() { \WP_REST_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_cache_by_endpoint( '/wp-json/wc/v3/products/categories', \WP_REST_Cache_Plugin\Includes\Caching\Caching::FLUSH_LOOSE ); }