diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php index e64176f036b..13f1f69e79d 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php @@ -1881,15 +1881,14 @@ class ProductCollection extends AbstractBlock { } $product = wc_get_product( $collection_args['upsellsProductReference'] ); - $upsells = array_map( - function ( $id ) { - return strval( $id ); - }, - $product->get_upsell_ids() - ); + if ( ! $product ) { + return array( + 'post__in' => array( -1 ), + ); + } return array( - 'post__in' => $upsells, + 'post__in' => $product->get_upsell_ids(), ); }, function ( $collection_args, $query ) {