Support » Plugin: Advanced AJAX Product Filters » Multiple select – filter is very slow

  • Resolved fkoomek

    (@fkoomek)


    Hello.
    I have a problem when selecting multiple choices. With every next ticked checkbox, the filter loads slower and slower. For example, when 8 checkboxes are checked, the load time is almost 10s, maybe more.
    I tried Woocommerce default attribute filter and the load time is still the same, no matter how many choices I choose.
    You can check here: https://test.liberlapidum.com/test/en/product-cat/minerals-precious-stones/
    The Woo default filter is on the left.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 16 through 22 (of 22 total)
  • Hello.
    Thank you for the information.
    Well, but the main problem was, that your filter is slower with every next chosen attribute right?
    And this issue still persists. Why Woocommerce default filter still takes the same time to load no matter how many attributes are chosen? And the default Woo filter even hides out of stock attributes and recalculate counts.

    Plugin Author Dima Holovnia

    (@dholovnia)

    Our developer did check the queries and the process.
    You have a lot of requests for products(with post_type=product). Looking at your page I could say that you don’t really need that much requests(300+). Most likely there is some issue or some plugins are conflicting.

    Our filters are done with best possible compatibility with other plugins. We are adding our filters to most of product requests. In common situation it is few requests. So our filters are loading fast AND more filters applied = faster speed of filtering.

    I don’t know why and what for there are so many product requests on your site but for sure this is the problem of the slowness. Translation plugin can double the amount but still there are too many requests. woof same as WooCommerce are adding there filters only to the main query.

    Probably in your case it is better to use some other plugin that will better fit your site’s configuration.

    Regards,
    Dima

    Hi Dima.
    Thank you so much for your help and your explanation.
    After what you wrote I started thinking, I disabled all plugins and then came to checking my customizations in functions.php in child theme. And I found it. It’s all caused by this piece of code: (After removing all is fine)

    /*Exclude categories with no visible products from  category widget*/
    function kfg_exclude_categories_from_widget( $category_list_args ) {
    	$args = array(
    		'hide_empty' => false,
    		'hierarchical' => true,
    	);
    	$product_categories = get_terms( 'product_cat', $args );
    	$exclude = array();
    	foreach ( $product_categories as $category ) {
    		$posts         = get_posts( array( 'post_type' => 'product', 'posts_per_page' => -1, 'product_cat' => $category->slug, 'fields' => 'ids' ) );
    		$show_category = false;
    		foreach ( $posts as $post ) {
    			$product         = new wC_Product( $post );
    			$visible_product = $product->is_in_stock();
    			if ( true === $visible_product ) {
    				$show_category = true;
    				break;
    			}
    		}
    		if ( false === $show_category ) {
    			$exclude[] = $category->term_id;
    		}
    	}
    	if ( ! empty( $exclude ) ) {
    		$category_list_args['exclude'] = implode( ',', $exclude );
    		unset( $category_list_args['include'] );
    	}
    	return $category_list_args;
    }
    add_filter( 'woocommerce_product_categories_widget_args', 'kfg_exclude_categories_from_widget', 10, 1 );

    Don’t you know how to edit this code, so that I could still use it an and also Ajax filter would work normally.? Thanks.

    Radan

    Plugin Author Dima Holovnia

    (@dholovnia)

    Hi Radan,

    
    $args = array(
        'hide_empty' => false,
        'hierarchical' => true,
    );
    $product_categories = get_terms( 'product_cat', $args );
    

    'hide_empty' => false, should be true

    After that remove from $category_list_args entities that are not presented in $product_categories.

    You over-complicated it a bit and creating a lot of unnecessary requests.

    Regards,
    Dima

    Great, thanks.
    I finally found out that I actually don’t need this code at all.

    Plugin Author Dima Holovnia

    (@dholovnia)

    Btw using 2 different filters plugin can provide negative impact also.

    For the live site it is better to use only 1 filter plugin.

Viewing 7 replies - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.