Commit b94348130a1 for woocommerce

commit b94348130a196ec99676d9b540e912c3df5c8687
Author: Luigi Teschio <gigitux@gmail.com>
Date:   Thu Oct 22 10:53:00 2026 +0200

    Simplify deprecated Products block registration (#70113)

    * Simplify deprecated Products block registration

    * Add changelog entries for Product Query registration

    * additional clean up

diff --git a/plugins/woocommerce/changelog/simplify-product-query-registration b/plugins/woocommerce/changelog/simplify-product-query-registration
new file mode 100644
index 00000000000..cd4719b90d9
--- /dev/null
+++ b/plugins/woocommerce/changelog/simplify-product-query-registration
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Simplify deprecated Products block registration; no intended user-facing change.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-query/variations/product-query.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/product-query/variations/product-query.tsx
index 4e52a7139c2..6d8612be751 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-query/variations/product-query.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-query/variations/product-query.tsx
@@ -1,118 +1,47 @@
 /**
  * External dependencies
  */
-import {
-	registerBlockVariation,
-	unregisterBlockVariation,
-} from '@wordpress/blocks';
+import { stacks } from '@woocommerce/icons';
+import { registerBlockVariation } from '@wordpress/blocks';
 import { Icon } from '@wordpress/components';
 import { __ } from '@wordpress/i18n';
-import { stacks } from '@woocommerce/icons';
-import { getSettingWithCoercion } from '@woocommerce/settings';
-import { select, subscribe } from '@wordpress/data';
-import {
-	QueryBlockAttributes,
-	ProductQueryBlockQuery,
-} from '@woocommerce/blocks/product-query/types';
-import { isSiteEditorPage, CORE_EDITOR_STORE } from '@woocommerce/utils';
-import { isNumber, isString } from '@woocommerce/types';

 /**
  * Internal dependencies
  */
 import {
-	PRODUCT_QUERY_VARIATION_NAME,
 	DEFAULT_ALLOWED_CONTROLS,
 	INNER_BLOCKS_TEMPLATE,
+	PRODUCT_QUERY_VARIATION_NAME,
 	QUERY_DEFAULT_ATTRIBUTES,
 	QUERY_LOOP_ID,
 } from '../constants';

-const ARCHIVE_PRODUCT_TEMPLATES = [
-	'archive-product',
-	'taxonomy-product_cat',
-	'taxonomy-product_tag',
-	'taxonomy-product_brand',
-	'taxonomy-product_attribute',
-	'product-search-results',
-];
-
-const registerProductsBlock = ( attributes: QueryBlockAttributes ) => {
-	registerBlockVariation( QUERY_LOOP_ID, {
-		description: __(
-			'A block that displays a selection of products in your store.',
-			'woocommerce'
-		),
-		name: PRODUCT_QUERY_VARIATION_NAME,
-		/* translators: "Products" is the name of the block. */
-		title: __( 'Products (Deprecated)', 'woocommerce' ),
-		isActive: ( blockAttributes ) =>
-			blockAttributes.namespace === PRODUCT_QUERY_VARIATION_NAME,
-		icon: (
-			<Icon
-				icon={ stacks }
-				className="wc-block-editor-components-block-icon wc-block-editor-components-block-icon--stacks"
-			/>
-		),
-		attributes: {
-			...attributes,
-			namespace: PRODUCT_QUERY_VARIATION_NAME,
-		},
-		// Gutenberg doesn't support this type yet, discussion here:
-		// https://github.com/WordPress/gutenberg/pull/43632
-		// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-		// @ts-ignore
-		allowedControls: DEFAULT_ALLOWED_CONTROLS,
-		innerBlocks: INNER_BLOCKS_TEMPLATE,
-		scope: [],
-	} );
-};
-
-let currentTemplateSlug: string | undefined;
-subscribe( () => {
-	const previousTemplateSlug = currentTemplateSlug;
-	currentTemplateSlug = select( CORE_EDITOR_STORE )?.getEditedPostSlug?.();
-	if ( previousTemplateSlug === currentTemplateSlug ) {
-		return;
-	}
-
-	if ( isSiteEditorPage() ) {
-		const inherit = ARCHIVE_PRODUCT_TEMPLATES.some( ( template ) =>
-			isString( currentTemplateSlug )
-				? currentTemplateSlug.includes( template )
-				: false
-		);
-
-		const inheritQuery: Partial< ProductQueryBlockQuery > = {
-			inherit,
-		};
-
-		if ( inherit ) {
-			inheritQuery.perPage = getSettingWithCoercion(
-				'loopShopPerPage',
-				12,
-				isNumber
-			);
-		}
-
-		const queryAttributes = {
-			...QUERY_DEFAULT_ATTRIBUTES,
-			query: {
-				...QUERY_DEFAULT_ATTRIBUTES.query,
-				...inheritQuery,
-			},
-		};
-
-		unregisterBlockVariation( QUERY_LOOP_ID, PRODUCT_QUERY_VARIATION_NAME );
-
-		registerProductsBlock( queryAttributes );
-	}
-}, CORE_EDITOR_STORE );
-
-let isBlockRegistered = false;
-subscribe( () => {
-	if ( ! isBlockRegistered && ! isSiteEditorPage() ) {
-		isBlockRegistered = true;
-		registerProductsBlock( QUERY_DEFAULT_ATTRIBUTES );
-	}
-}, CORE_EDITOR_STORE );
+registerBlockVariation( QUERY_LOOP_ID, {
+	description: __(
+		'A block that displays a selection of products in your store.',
+		'woocommerce'
+	),
+	name: PRODUCT_QUERY_VARIATION_NAME,
+	/* translators: "Products" is the name of the block. */
+	title: __( 'Products (Deprecated)', 'woocommerce' ),
+	isActive: ( blockAttributes ) =>
+		blockAttributes.namespace === PRODUCT_QUERY_VARIATION_NAME,
+	icon: (
+		<Icon
+			icon={ stacks }
+			className="wc-block-editor-components-block-icon wc-block-editor-components-block-icon--stacks"
+		/>
+	),
+	attributes: {
+		...QUERY_DEFAULT_ATTRIBUTES,
+		namespace: PRODUCT_QUERY_VARIATION_NAME,
+	},
+	// Gutenberg doesn't support this type yet, discussion here:
+	// https://github.com/WordPress/gutenberg/pull/43632
+	// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+	// @ts-ignore
+	allowedControls: DEFAULT_ALLOWED_CONTROLS,
+	innerBlocks: INNER_BLOCKS_TEMPLATE,
+	scope: [],
+} );
diff --git a/plugins/woocommerce/client/blocks/changelog/simplify-product-query-registration b/plugins/woocommerce/client/blocks/changelog/simplify-product-query-registration
new file mode 100644
index 00000000000..cd4719b90d9
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/changelog/simplify-product-query-registration
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Simplify deprecated Products block registration; no intended user-facing change.