Commit 9d1bf50726c for woocommerce

commit 9d1bf50726c7edc530602be077de54ce46bc885a
Author: Panos (Panagiotis Synetos) <2484390+PanosSynetos@users.noreply.github.com>
Date:   Thu May 7 16:14:43 2026 +0300

    Fix Catalog Sorting block assets returning 404 (#64682)

    * Fix Catalog Sorting block 404s for non-existent JS and CSS assets

    After the iAPI migration in #62854, the Catalog Sorting block loads
    its frontend logic via viewScriptModule declared in block.json, but
    the PHP class still inherited AbstractBlock's default script/style
    registration. That default derives paths from $block_name
    (assets/client/blocks/catalog-sorting.js / .css), neither of which
    exists, so WordPress enqueues handles that 404.

    Use EnableBlockJsonAssetsTrait to opt out of the AbstractBlock-driven
    script/style/editor-style registration. The iAPI module is registered
    through block.json and the block has no stylesheet.

    * Fix typo in variable name preventing inline styles from being applied

    $styles_and_classes was undefined (swapped name), so the wrapper's
    inline style attribute always fell through to the empty default.
    Use the correct $classes_and_styles variable assigned above.

    * PHPStan

diff --git a/plugins/woocommerce/changelog/wooplug-6660-iapi-catalog-sorting-block-404-css-and-js b/plugins/woocommerce/changelog/wooplug-6660-iapi-catalog-sorting-block-404-css-and-js
new file mode 100644
index 00000000000..31d05cef222
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-6660-iapi-catalog-sorting-block-404-css-and-js
@@ -0,0 +1,5 @@
+Significance: patch
+Type: fix
+Comment: Prevent 404s for Catalog Sorting block assets.
+
+Catalog Sorting block: prevent 404s for non-existent JS and CSS asset files.
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index c48f3f61cae..c90a3ebe0cc 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -51615,12 +51615,6 @@ parameters:
 			count: 1
 			path: src/Blocks/BlockTypes/CatalogSorting.php

-		-
-			message: '#^Variable \$styles_and_classes on left side of \?\? is never defined\.$#'
-			identifier: nullCoalesce.variable
-			count: 1
-			path: src/Blocks/BlockTypes/CatalogSorting.php
-
 		-
 			message: '#^Cannot call method allocate_and_return_parsed_attributes\(\) on Automattic\\Block_Scanner\|null\.$#'
 			identifier: method.nonObject
@@ -53805,7 +53799,6 @@ parameters:
 			count: 1
 			path: src/Blocks/BlockTypes/ProductFilterRating.php

-
 		-
 			message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: \(0\|1\) given\.$#'
 			identifier: argument.type
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php b/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php
index be39d3c118a..664bf59b714 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php
@@ -10,6 +10,8 @@ use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;
  */
 class CatalogSorting extends AbstractBlock {

+	use EnableBlockJsonAssetsTrait;
+
 	/**
 	 * Block name.
 	 *
@@ -63,7 +65,7 @@ class CatalogSorting extends AbstractBlock {
 						]
 					)
 				),
-				'style' => esc_attr( $styles_and_classes['styles'] ?? '' ),
+				'style' => esc_attr( $classes_and_styles['styles'] ?? '' ),
 			)
 		);