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
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:
-
Create configurable products:
- Product 1:
config1withoption1 - Product 2:
config2withoption2
- Product 1:
-
Create and assign products to a category
- Create a new category.
- Assign both products (
config1andconfig2) to this category.
-
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
-
Run the following Magento CLI commands:
code language-bash bin/magento indexer:reindex bin/magento cache:clean -
Send a POST request to
../graphqlwith 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:
- Adobe Commerce or Magento Open Source on-premises: Quality Patches Tool > Usage in the Quality Patches Tool guide.
- Adobe Commerce on cloud infrastructure: Upgrades and Patches > Apply Patches in the Commerce on Cloud Infrastructure guide.
Related reading
To learn more about Quality Patches Tool, refer to:
- Quality Patches Tool: A self-service tool for quality patches in the Tools guide.