Related products performance issue - by davidturnbull72

This topic has 7 replies, 2 voices, and was last updated 9 years, 7 months ago ago by Eva Kemp

  • Avatar: davidturnbull72
    davidturnbull72
    Participant
    May 7, 2015 at 15:42

    Hi,

    I am nearing completion of development for a client using the Woopress theme, and I have noticed a performance issue when displaying related products on a single product page.

    I have narrowed it down to the etheme_create_slider function in theme-functions.php and more specifically, the following while loop:

    while ($multislides->have_posts()) : $multislides->the_post();
    $_i++;

    if(class_exists(‘Woocommerce’)) {
    global $product;
    if (!$product->is_visible()) continue;
    echo ‘<div class=”slide-item product-slide ‘.$slider_type.’-slide”>’;
    woocommerce_get_template_part( ‘content’, ‘product-slider’ );
    echo ‘</div><!– slide-item –>’;
    }

    endwhile;

    I have put some timing debugging code at the beginning and of the function – and its taking 8 seconds in some cases to execute the function – see private content for live example.

    Many thanks

    Please, contact administrator
    for this information.
    6 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    May 7, 2015 at 15:52

    Hello,

    Sorry, but your query is unclear.
    Could you please clarify with more details what you’re trying to achieve?

    Thank you.
    Regards,
    Eva Kemp.

    Avatar: davidturnbull72
    davidturnbull72
    Participant
    May 7, 2015 at 15:58

    Hi,

    There appears to be a problem with the theme when viewing a product- the related products section is taking a very long time (e.g. approx 8 seconds) to be displayed.

    If you view the link I supplied in the private section, you will see this behaviour. I have also echo’d time-stamps before and after the code that generates the related products to demonstrate that its that code causing the problem and the time it is taking.

    Many thanks

    Avatar: Eva
    Eva Kemp
    Support staff
    May 7, 2015 at 17:49

    Hello,

    You can speed up the site following the suggestions from these articles:
    http://codex.wordpress.org/WordPress_Optimization
    http://techtage.com/speeding-up-wordpress-sites/
    http://www.sparringmind.com/speed-up-wordpress/

    Thank you.
    Regards,
    Eva Kemp.

    Avatar: davidturnbull72
    davidturnbull72
    Participant
    May 7, 2015 at 18:05

    Hi,

    I’m not sure you understand. Its not the general wordpress site performance – its a specific a piece of code in the woopress theme.

    When I disable ‘display related products’ in the theme options, the site’s performance is fine. When I enable that feature its takes about 8 seconds for that code to generate and display the related products – that shouldn’t be the case.

    Please advise.
    Thanks

    Avatar: davidturnbull72
    davidturnbull72
    Participant
    May 11, 2015 at 11:41

    Hi,

    I have managed to alleviate the problem by reducing the number of items that it attempts to display in the slider by adding the following filter function:

    add_filter (‘woocommerce_related_products_args’, ‘rev_related_products_args’,1);
    function rev_related_products_args ($args) {
    $args[‘posts_per_page’] = 8;
    return $args;
    }

    Without it, it defaults the posts_per_page to (in my case) 50 – which results in terrible performance as it creates the slider.

    David

    Avatar: Eva
    Eva Kemp
    Support staff
    May 11, 2015 at 11:59

    Hello,

    We ‘re glad you managed to resolve the issue.

    If there are any questions feel free to contact us.

    Regards,
    Eva Kemp.

  • Viewing 7 results - 1 through 7 (of 7 total)

The issue related to '‘Related products performance issue’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.