Fix: Upsells collection not showing correct products on frontend (#51730)

* Fix: Upsells collection not showing correct products on frontend

This commit addresses an issue where the Upsells collection wasn't displaying the correct products on the frontend. The problem was caused by a variable name mismatch in the condition checking for empty product references.

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

* Rename product_references variable for consistency

* Update variable name

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
This commit is contained in:
Manish Menaria 2024-10-22 12:56:06 +05:30 committed by GitHub
parent e6d0a906fb
commit 0d9d06cd46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Product Collection: Fix Upsells collection not showing linked product on Frontend on Single Product Template

View File

@ -2053,7 +2053,7 @@ class ProductCollection extends AbstractBlock {
function ( $collection_args, $query ) {
$product_references = isset( $query['productReference'] ) ? array( $query['productReference'] ) : null;
// Infer the product reference from the location if an explicit product is not set.
if ( empty( $product_reference ) ) {
if ( empty( $product_references ) ) {
$location = $collection_args['productCollectionLocation'];
if ( isset( $location['type'] ) && 'product' === $location['type'] ) {
$product_references = array( $location['sourceData']['productId'] );