BEAR - WooCommerce Bulk Editor and Products Manager Professional

WooCommerce search variations by SKU in the bulk editor

You type a SKU into the quick search of the bulk editor, switch on variations, and the variable product appears with only some of its variations, or with none at all. Search by title and every variation is there. This is how a WooCommerce search for variations by SKU works in BEAR, not a fault: it compares the SKU that each product and each variation stores itself, and a variation without its own SKU has nothing to compare. Below is what the SKU search returns, how to see or edit any variation, how to make SKU the default quick search field, and how to search by meta fields, brands and categories.

WooCommerce search variations by SKU: what the table shows

The quick search sits on the tools panel above the table: a text box with the placeholder quick search by ..., a field drop-down (Title, SKU, ID) and a behaviour drop-down (LIKE, EXACT, NOT, BEGIN, END). Press Enter or click the button next to it. The quick search is a shortcut to the Filters tab: it empties every filter field, copies your text into the chosen field there and runs the filter.

A SKU search looks in the _sku value of products and variations alike. A product is listed when its own SKU matches or when one of its variations matches. With the variations switch on, the table then lists under each product only the variations whose own SKU matches too. Take a hoodie with the SKU HOOD, two variations HOOD-S and HOOD-M, and a third variation with an empty SKU field:

SearchBehaviourProduct rowVariation rows
HOODLIKEyesHOOD-S and HOOD-M, not the one without a SKU
HOODEXACTyesnone
HOOD-MEXACTyesHOOD-M only
HOOD-S, HOOD-MEXACTyesHOOD-S and HOOD-M

Separate several SKUs with commas, as in the last row. EXACT needs the complete SKU, LIKE finds a part of it, BEGIN and END match its start or end. The variation filter is the point of the design: a SKU search answers "where is this item", so the table shows the matching variations instead of burying them among all the others. The price, stock and weight filters work the same way.

Why variations that show the parent's SKU are not found

In WooCommerce a variation's SKU field may stay empty. The variation then displays the parent's SKU: on the product page, in the order and in the SKU column of the editor, which shows SKUs the way WooCommerce does. Nothing is stored on the variation, though, so the search has nothing to compare with. That is the variation without a SKU in the example: the table shows HOOD in its SKU cell, yet no SKU search lists it.

To find these variations, open the Filters tab, leave the SKU field empty and choose the behaviour Empty. It lists products and variations without a SKU of their own. In 2.2.4 it looks at published products and enabled variations only, so check drafts and disabled variations by hand.

The lasting fix is to give the variations their own SKUs. You do not have to type them: a bulk edit of the variations can build each one from the parent's SKU and the variation's attribute or ID, as described in WooCommerce bulk edit SKU. Variations that BEAR creates from attribute combinations in Variations Advanced Bulk Operations already get one: the parent's SKU plus the variation ID, such as HOOD-1542, which a LIKE search for HOOD finds.

See all variations of a product, or edit one

When you need every variation of the product you found, search by something the variations share with their parent rather than by SKU:

  • Title with LIKE. WooCommerce names variations after their product, such as Hoodie - Blue, so a part of the product name matches the product and all of its variations. With EXACT only the product matches, because the full variation titles are longer.
  • ID of the product. The ID search selects products and leaves their variations alone, so all of them are listed. It accepts several IDs and ranges, such as 1201,1240-1245. A variation's own ID finds nothing here: search the variation by its SKU instead.

To change one variation, for example the stock of one size, switch on variations first: with the switch off the table shows only the product row, even when the search matched a variation. Then search the variation's own SKU with EXACT and edit the cell in the variation row. The column you edit must be switched on in the Settings tab.

Bulk edit only the variations the search found

One thing surprises people here. With variations on and no row ticked, the Bulk Edit tab applies to the filtered products, and for each of them it takes all of its variations, including the ones the SKU search hid. The table filter decides which products are affected, not which variations.

To limit a bulk edit to the variations you see, tick them. The select all variations button on the tools panel ticks every variation row of the page and none of the products; then run the bulk edit or use binded editing. The button reaches only the rows of the current page, so show enough rows first, see more rows per page. To choose variations by attribute value rather than by SKU, use the attribute combinations described in filter variations by attribute.

Make SKU the default quick search field

The quick search opens with Title selected. If you search mostly by SKU, reorder the field list with the woobe_quick_search_options filter: the first entry becomes the default. Do not edit the plugin's files for this, an update overwrites them.

/*
 * BEAR bulk editor: open the quick search with SKU selected.
 * Child theme functions.php or a code snippets plugin.
 */
add_filter( 'woobe_quick_search_options', function ( $options ) {
    if ( isset( $options['sku'] ) ) {
        // put SKU first, keep Title, ID and the rest after it
        $options = array( 'sku' => $options['sku'] ) + $options;
    }
    return $options;
} );

Reload the editor page; the field drop-down now starts with SKU, and the behaviour stays LIKE.

Search by a meta field, brand or category

The quick search works with text fields that have a text box in the Filters tab. Besides title, SKU and ID these are content, excerpt, slug and product URL, plus meta fields of the type string. Add them to the field drop-down in the Settings tab, option Add fields to the quick search, as key:Label pairs separated by commas:

post_name:Product slug,post_content:Content,_supplier_code:Supplier code

A custom meta field such as _supplier_code must exist in the editor first: add it in the Meta Fields tab with the type string and switch its column on in Settings. It then appears in the Filters tab with the behaviours LIKE, EXACT (=), NOT EXACT (!=), NOT LIKE, Empty and NOT Empty, and the quick search can use it. Meta field searches look at the products, not at values stored on variations. If you do not know the key, see how to find a product meta key.

Brands, categories, tags and global attributes are taxonomies, not text. Entering product_cat or product_brand in Add fields to the quick search adds an entry to the drop-down, but the text you type is ignored, because no text box exists behind it. Filter them in the Filters tab instead: every product taxonomy, the WooCommerce Brands taxonomy included, has its own term selector there with OR, AND and NOT IN. To combine a category with a SKU, fill both in the Filters tab; the quick search would empty the category again.

If the search still finds nothing

  1. Check the behaviour: EXACT with a part of a SKU finds nothing.
  2. Switch on variations if you expect variation rows.
  3. Filter the SKU with Empty to see whether the variations have SKUs of their own.
  4. When you search in the Filters tab instead of the quick search, click Reset first, so that no older filter value is combined with yours.
  5. If no search works at all, or the result is lost on page 2, the cause is caching or the plugin's memory storage, see bulk editor filter not working.
  6. To list several products by title at once, use the special syntax described in multiple titles in the search box.

If variations with their own matching SKU are still missing, ask on the BEAR support forum with the SKU you searched and the behaviour you used.