New product filtering by attributes rolling out in WooCommerce 6.3

Finally! After having been an opt-in feature for some time, the new product filtering mechanism we announced a few months ago is rolling out for everybody in WooCommerce 6.3. Here’s what you need to know as a shop administrator.

What’s going to happen after I upgrade to/install WooCommerce 6.3?

A database migration will kick in. This will create the new product attributes lookup table and will trigger a recursive scheduled action that will fill it; you can verify that this is the case by opening the WooCommerce tools page (WooCommerce – Status – Tools), you should see a new entry titled “Regenerate the product attributes lookup table” with a disabled button that displays a number:

The number indicates how many products have been processed so far (10 products are processed in each batch by default, more on that later). Note that “processed” in this context means that the appropriate entries will have been created in the new lookup table. From the point of view of the products themselves, this is a read-only process and no modifications will happen whatsoever for any product.

Once the process has finished the button will appear as enabled and its label will be “Regenerate”. But more interestingly, a new settings section will become available as well.

The new settings

Once the initial database migration has finished a new “Advanced” section will appear in the product settings tab (WooCommerce – Settings – Products – Advanced) with a couple of options related to this new feature:

“Use the product attributes lookup table for catalog filtering” instructs WooCommerce to effectively use the new lookup table for the shop catalog display and filtering, it will have been enabled automatically after the database migration finishes but you can enable and disable it at will (when disabled, the posts table will be used instead, as it was the case when the lookup table wasn’t available).

“Update the table directly upon product changes, instead of scheduling a deferred update” determines how the lookup table will be updated whenever a product is created or updated: when enabled, the update will happen immediately; otherwise, the action scheduler will do the update job some (short) time after the product is created or updated.

Important: WooCommerce will always create or update the appropriate entry in the lookup table whenever a product is created or updated, even when the “Enable table usage” setting is off. This is necessary to guarantee data consistency in all cases, regardless of whether the table usage is set on or off.

Regenerating the lookup table data

As mentioned before, once the initial database migration is completed the “Regenerate the product attributes lookup table” tool will be available. You’ll see that there’s a product selector next to it, thus you can use this tool in two ways:

  • Select a product: the tool will regenerate the lookup data for only that product, immediately.
  • Don’t select a product: the tool will start over the initial data migration, by first emptying the table and then fillin in within a recursive scheduled action.

Worth noting that while the full table regeneration is in progress the table usage will of course be disabled and you won’t be able to enable it via settings.

This tool is intended as an emergency mechanism only, in case there’s something wrong with the implementation of the feature and the table ends up having missing or wrong data. As a general rule, we don’t recommend using this tool unless you are instructed to do so by a WooCommerce support person.

Customizing the table (re)generation batch size

By default, when the lookup table is being filled (during the initial database migration, or when you trigger a full table regeneration via the dedicated tool) 10 products will be processed in each run of the action scheduler. This number is slow on purpose, in order to keep the performance penalty of the ongoing migration to a minimum; but it can cause the entire process to take too much time in shops with a large number of products.

This value can be customized by using the woocommerce_attribute_lookup_regeneration_step_size filter like this:

add_filter('woocommerce_attribute_lookup_regeneration_step_size', function() {
    return 100;
});

You can use the WordPress code snippets plugin to add this piece of code.

It’s worth noting that this filter can be added (or the returned value can be modified) even when the initial database migration or the manually triggered table regeneration is already running: the next action scheduler run will pick the new value and use it on all subsequent runs.


6 responses to “New product filtering by attributes rolling out in WooCommerce 6.3”

  1. pacmanito Avatar

    Kudos! You’ve fixed one of the long-standing WooCommerce weaknesses.
    I hope this related enhancement https://github.com/woocommerce/woocommerce/issues/31688 will be implemented soon.

    1. jonnyporter Avatar
      jonnyporter

      A comment by the author of this post near the bottom of the page you link to implies that it was indeed done.

  2. Great news! This should help speed issues for stores running products with complex variations.

  3. Heads up: The first image in this article is not displaying for me. It’s coming back with a 403 error.

  4. This is great. Congratulations!

  5. Any thoughts on solving the issue whereby the attribute looking regenerate can and will not be update-able via CRON job?

    This new feature, while great to see — ignores anything that is uploaded via CSV sheet and we need a way to periodically run these updates in the background.

    This issue with CRON jobs is well documented, but in short:

    The job will run successfully, but nothing changes.

Leave a Reply

Your email address will not be published. Required fields are marked *