Commit 493c070db70 for woocommerce

commit 493c070db70264c492b7ef0de9ca2e631d071128
Author: Alba Rincón <albarin@users.noreply.github.com>
Date:   Wed Mar 18 13:15:15 2026 +0100

    Add cache priming to linked products meta box and sales report (#63737)

    * Add cache priming to linked products meta box and sales report

    * Add changefile(s) from automation for the following project(s): woocommerce

    * Add changefile(s) from automation for the following project(s): woocommerce

    ---------

    Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/63737-add-cache-priming-admin-meta-boxes-reports b/plugins/woocommerce/changelog/63737-add-cache-priming-admin-meta-boxes-reports
new file mode 100644
index 00000000000..fb45e71e8da
--- /dev/null
+++ b/plugins/woocommerce/changelog/63737-add-cache-priming-admin-meta-boxes-reports
@@ -0,0 +1,4 @@
+Significance: patch
+Type: performance
+
+Reduce the number of SQL queries on the linked products meta box and sales by product report by adding missing cache priming.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-linked-products.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-linked-products.php
index 9b88e60694e..ff1e78af32f 100644
--- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-linked-products.php
+++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-linked-products.php
@@ -18,6 +18,11 @@ defined( 'ABSPATH' ) || exit;
 				<?php
 				$product_ids = $product_object->is_type( ProductType::GROUPED ) ? $product_object->get_children( 'edit' ) : array();

+				if ( ! empty( $product_ids ) ) {
+					// Prime caches to reduce future queries.
+					_prime_post_caches( $product_ids );
+				}
+
 				foreach ( $product_ids as $product_id ) {
 					$product = wc_get_product( $product_id );
 					if ( is_object( $product ) ) {
@@ -36,6 +41,11 @@ defined( 'ABSPATH' ) || exit;
 				<?php
 				$product_ids = $product_object->get_upsell_ids( 'edit' );

+				if ( ! empty( $product_ids ) ) {
+					// Prime caches to reduce future queries.
+					_prime_post_caches( $product_ids );
+				}
+
 				foreach ( $product_ids as $product_id ) {
 					$product = wc_get_product( $product_id );
 					if ( is_object( $product ) ) {
@@ -52,6 +62,11 @@ defined( 'ABSPATH' ) || exit;
 				<?php
 				$product_ids = $product_object->get_cross_sell_ids( 'edit' );

+				if ( ! empty( $product_ids ) ) {
+					// Prime caches to reduce future queries.
+					_prime_post_caches( $product_ids );
+				}
+
 				foreach ( $product_ids as $product_id ) {
 					$product = wc_get_product( $product_id );
 					if ( is_object( $product ) ) {
diff --git a/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-product.php b/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-product.php
index 9c76a06031a..a365dd78f60 100644
--- a/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-product.php
+++ b/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-product.php
@@ -195,6 +195,11 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {

 		$this->product_ids_titles = array();

+		if ( ! empty( $this->product_ids ) ) {
+			// Prime caches to reduce future queries.
+			_prime_post_caches( $this->product_ids );
+		}
+
 		foreach ( $this->product_ids as $product_id ) {

 			$product = wc_get_product( $product_id );