Skip to content

fix(woocommerce): do not integrate queries for product variations - #4350

Open
faisalahammad wants to merge 1 commit into
10up:developfrom
faisalahammad:fix/3887-wc-single-variations-conflict
Open

fix(woocommerce): do not integrate queries for product variations#4350
faisalahammad wants to merge 1 commit into
10up:developfrom
faisalahammad:fix/3887-wc-single-variations-conflict

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Summary

The WooCommerce feature listed product_variation as a default supported post type. Third party plugins such as WooCommerce Single Variations add product_variation to the post type on frontend queries. Those queries were then served by Elasticsearch, and the posts_pre_query filter skipped the SQL hooks those plugins rely on, which broke them.

This change removes product_variation from the default supported post types. Queries that include it now run against MySQL and keep the normal query hooks. Sites that want ElasticPress to handle product variation queries can still opt in through the ep_woocommerce_products_supported_post_types filter.

Fixes #3887

Changes

includes/classes/Feature/WooCommerce/Products.php

Before:

$post_types = [ 'product_variation' ];

After:

$post_types = [];

Why: product_variation is never queried as a post type by any core WooCommerce frontend flow. Keeping it in the default list made every query that contains it (often added by third party plugins) integrate with Elasticsearch and skip the normal query hooks.

tests/php/features/WooCommerce/TestWooCommerceProduct.php

  • testGetSupportedPostTypes updated: product_variation is no longer part of the default supported post types, and product is returned when ep_integrate is explicitly true.
  • New test testProductVariationQueryDoesNotIntegrate: a query with post_type = ['product', 'product_variation'] and ep_integrate = true must not trigger ElasticPress integration.

Testing

Test 1: Regression test

  1. Run composer test -- --filter='testGetSupportedPostTypes|testProductVariationQueryDoesNotIntegrate'
  2. All 3 tests pass (9 assertions).

Test 2: Full WooCommerce product suite

  1. Run composer test -- --filter='TestWooCommerceProduct'
  2. 56 tests pass. One pre-existing failure (testPriceFilterWithTax) is unrelated and reproduces on a clean develop branch.

Test 3: Manual

  1. Install ElasticPress and the WooCommerce Single Variations plugin by welaunch.
  2. Enable the WooCommerce feature and index.
  3. Open a shop or category page.
  4. Product variations appear as standalone products, same as without ElasticPress.

product_variation was part of the default supported post types for the
WooCommerce feature. Queries containing product_variation, like the ones
built by third party plugins such as WooCommerce Single Variations, were
then served by Elasticsearch. The posts_pre_query filter skips the SQL
hooks those plugins rely on, breaking them.

Remove product_variation from the default supported post types. Queries
that include it now run against MySQL and keep the normal query hooks.
Sites that want ElasticPress to handle product variation queries can
still opt in through the ep_woocommerce_products_supported_post_types
filter.

Fixes 10up#3887
@felipeelia felipeelia added this to the 5.4.0 milestone Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: deactivate another plugin

2 participants