• Resolved Thomas Jarvis

    (@thomasjarvisdesign)


    I have two extremely large Ecommerce sites (one in link included with post, the other not included)

    One has 58,000 products one has 116,000 variations over a few thousand products.

    I get the following message and the process seems to take far too long. It is causing issues with caching and causing any database query to run slowly.

    WooCommerce is updating product data in the background
    Product display, sorting, and reports may not be accurate until this finishes. It will take a few minutes and this notice will disappear when complete.

    I have disabled Cron and set cron to trigger from the server to try and minimise the impact of this process.

    We have reviews turned off – Why is Woocommerce still counting ratings?

    wc_update_product_lookup_tables_rating_count_batch

    Is it possible to disable this scheduled task if we have reviews turned off?

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Thomas Jarvis

    (@thomasjarvisdesign)

    More information:

    The script that runs is here:
    woocommerce/includes/wc-product-functions.php

    But I have reviews and average rating disabled in Woocommerce settings so it really does not need to calculate the average ratings of products.

    I have commented out line 1659. This prevents the batch counter running. I am not sure if this will cause any serious problems? Not sure if this is anything you have looked at before?

    Can you confirm what disabling this function will do? and whether it will stop the table regenerating or just stop ratings regenerating.

    Hi there ??

    Welcome to WooCommerce Support. I’d be happy to help you with this.

    I have disabled Cron and set cron to trigger from the server to try and minimise the impact of this process.

    We have reviews turned off – Why is Woocommerce still counting ratings?

    wc_update_product_lookup_tables_rating_count_batch

    Is it possible to disable this scheduled task if we have reviews turned off?

    This sounds like it could possibly be due to errant code in a theme or plugin. Below, I am attaching a couple screenshots of a test installation of mine, for reference:

    Direct link to image: https://snipboard.io/hPBnV2.jpg
    Direct link to image: https://snipboard.io/9Pnb7T.jpg

    Just to clarify, did you already have a chance to deactivate all plugins except WooCommerce and switch to a default theme like Storefront theme (linked here), and see if the issue persists, or otherwise? If not, you can narrow down the cause by restoring your theme first and then all plugins, one at a time, until the problem returns. Linked here is the official guide, for performing such a conflict test.

    Also, what version of WooCommerce each of the two stores have activated? Do they have High-Performance Order Storage (HPOS) mode activated, or otherwise? Feel free to visit the?documentation page?for more details on the High-Performance Order Storage (HPOS). I’ll go ahead and?link to this announcement also, for your convenience.

    Before making changes, save/export the current database to your own computer as a backup. If anything goes wrong, then this can help you.

    I hope this is helpful! Please let us know if you have any further questions or concerns.
    We will be happy to help you further.

    Thread Starter Thomas Jarvis

    (@thomasjarvisdesign)

    Sorry No but the explanation below explains the issue clearly – I have not used a default theme because that wont affect the callback function.

    But I can see the average_rating being unserialised and updated regardless of whether reviews are on or off.

    You can see that when it runs the function to update the product attribute lookup table – It always calls the average rating column to be updated even if reviews are off.

    Woocommerce > Includes > wc-product-functions.php

    On line 1414 you can see that it always looks up update average rating – There is no exception for when reviews are disabled.

    On line 1659 you can see it still counts the ratings in batches even if reviews are disabled.

    The solution is for woocommerce to add an exception to this query so average_rating is excluded if reviews are disabled.

    The function being triggered is part of the new Product Attribute Lookup Table functions.

    I have commented out line 1659 – This causes the wc_update_product_lookup_tables_rating_count_batch to cease after the first batch of 50. Stopping the table updates taking forever.

    It states in the code on line 1438 that rating counts are serialised so it has to unserialise them before it can update the lookup table. This is a pointless exercise if reviews are disabled globally and just slows down the product attribute table updates.

    Proposed solution:

    Add an exception to the script so that if reviews are off – It doesnt update the reviews column.

    Saif

    (@babylon1999)

    Hello @thomasjarvisdesign,

    Thank you for bringing this to our attention!

    It states in the code on line 1438 that rating counts are serialised so it has to unserialise them before it can update the lookup table. This is a pointless exercise if reviews are disabled globally and just slows down the product attribute table updates.

    I agree with all the points you’ve mentioned. There should be a way to avoid scheduling this action when reviews are disabled. Since you’ve already looked into the cause of the issue, I recommend posting an enhancement request to the developers. You can do this by visiting the following link: https://github.com/woocommerce/woocommerce/issues/new/choose

    As an additional suggestion, you can potentially remove the callback function by adding the following snippet via CodeSnippets (please add it at your own risk).

    remove_action('wc_update_product_lookup_tables_rating_count_batch', 'wc_update_product_lookup_tables_rating_count_batch', 10, 2);
    

    This might serve as a better workaround if you don’t want the action to consume server resources, given that all the changes you made will be removed when you update WooCommerce.

    Let us know if you have any other questions! :?)

    Thread Starter Thomas Jarvis

    (@thomasjarvisdesign)

    Thank you for the functions.php addition. Perfect for me but not ideal for average users.

    I have raised the enhancement request on Github

    Thank you for the snippet. I’ll impliment this on my sites.

    Thread Starter Thomas Jarvis

    (@thomasjarvisdesign)

    Just folloiwing up from this. – The snippet really helps speed up the wp-cron attibute table updates so I have kept it on my two largest sites.

    This really should be the default setting!

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @thomasjarvisdesign

    I’m glad we were able to help!

    If it isn’t too much to ask for – would you mind leaving us a review here?

    It only takes a couple of minutes but helps us tremendously. It would mean so much to us and would go a really long way.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable wc_update_product_lookup_tables_rating_count_batch’ is closed to new replies.