[PaaS only]{class="badge informative" title="Applies to Adobe Commerce on Cloud projects (Adobe-managed PaaS infrastructure) and on-premises projects only."}

ACSD-66072: GraphQL fails to return related products on the Product Detail Page

The ACSD-66072 patch fixes the issue where related products are not returned via GraphQL on the Product Detail Page due to an internal server error when Related Products Rule is configured. This patch is available when the Quality Patches Tool (QPT) 1.1.68 is installed. The patch ID is ACSD-66072. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.9.

Affected products and versions

The patch is created for Adobe Commerce version:

  • Adobe Commerce (all deployment methods) 2.4.6-p8

Compatible with Adobe Commerce versions:

  • Adobe Commerce (all deployment methods) 2.4.6 - 2.4.8-p1
NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Related products are not returned via GraphQL on the Product Detail Page due to an internal server error when Related Products Rule is configured.

Steps to reproduce:

  1. Create configurable products:

    • Product 1: config1 with option1
    • Product 2: config2 with option2
  2. Create and assign products to a category

    • Create a new category.
    • Assign both products (config1 and config2) to this category.
  3. Navigate to Marketing > Promotions > Related Products Rule, then create a new rule with the following settings:

    • Priority: 1
    • Applies To: Related Products
    • Result Limit: 10
    • Products to Match: Attribute Set is Default
    • Products to Display: Product Category is the Same as Matched Product Categories
  4. Run the following Magento CLI commands:

    code language-bash
    bin/magento indexer:reindex
    bin/magento cache:clean
    
  5. Send a POST request to ../graphql with the following payload:

    code language-none
    query getRelatedProductsForProductPage($urlKey: String!)
    {
        products(filter: { url_key: { eq: $urlKey } })
        {
            items {
                id
                __typename
                uid
                url_key
                name
                sku
                related_products {
                    id
                    uid
                    name
                    sku
                    stock_status
                    url_key
                    small_image {
                        url
                        __typename
                        }
                        thumbnail {
                            url
                            __typename
                            }
                            image {
                                url
                                __typename
                                }
                                price_range {
                                    maximum_price {
                                        regular_price {
                                            currency
                                            value
                                            __typename
                                            }
                                            __typename
                                            }
                                            minimum_price {
                                                discount {
                                                    amount_off
                                                    percent_off
                                                    __typename
                                                    }
                                                    final_price {
                                                        currency
                                                        value
                                                        __typename
                                                        }
                                                        regular_price {
                                                            currency
                                                            value
                                                            __typename}
                                                            __typename}
                                                            __typename}
                                                            __typename
                                                            }
                                                            }
                                                            __typename
                                                            }
                                                            }
    

Expected results:

The query returns the related product (config1).

Actual results:

{
    "errors": [
        {
            "message": "Internal server error",
            "locations": [
                {
                    "line": 10,
                    "column": 7
                }
            ],
            "path": [
                "products",
                "items",
                0,
                "related_products"
            ]
        }
    ],
    "data": {
        "products": {
            "items": [
                {
                    "id": 4,
                    "__typename": "ConfigurableProduct",
                    "uid": "NA==",
                    "url_key": "config2",
                    "name": "config2",
                    "sku": "config2",
                    "related_products": null
                }
            ],
            "__typename": "Products"
        }
    }
}

The var/log/exception.log file contains:

report.ERROR: Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/magento2ee/app/code/Magento/TargetRule/Model/ResourceModel/Index.php on line 557

Apply the patch

To apply individual patches, use the following links depending on your deployment method:

To learn more about Quality Patches Tool, refer to:

recommendation-more-help
c2d96e17-5179-455c-ad3a-e1697bb4e8c3