Skip to content

Graphql price tiers returning data from previous item in foreach #32279

Closed
@treestonemedia

Description

@treestonemedia

Preconditions

  1. Clean Magento 2.4.2 with sample data
  2. 2.4-develop

Steps to reproduce (*)

  1. Install clean Magento 2.4.2 with sample data
  2. Add tier pricing to any item (for this example we added tier prices to items ID 1 & 2)
  3. run Graphql query with search that will include the item with tier prices and items without tier prices
{
  products(pageSize: 20, currentPage: 1, search: "24-MB0") {
    items {
      id
      price_tiers {
        quantity
        final_price {
          value
        }
      }
    }
  }
}
{code}

### Expected result (*)

1. Items with tier price return correct tier pricing, items without tier pricing return no tier prices
{code}
{{
{
    "data": {
        "products": {
            "items": <
                {
                    "id": 42,
                    "price_tiers": []
                },
				...
                {
                    "id": 17,
                    "price_tiers": []
                },
                {
                    "id": 1,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 23,
                    "price_tiers": []
                },
                {
                    "id": 19,
                    "price_tiers": []
                },
				...
            ]
        }
    }
}
}}
{code}

### Actual result (*)

1. All items coming after an item with tier pricing have tier pricing in the response
1. The tier pricing data that it's returning is from the last item in the loop that had tier pricing
1. in our example, items ID 1 & ID 2 are the only ones that have tier pricing, yet here is the result

{code}
{
    "data": {
        "products": {
            "items": [
                {
                    "id": 42,
                    "price_tiers": []
                },
                {
                    "id": 2046,
                    "price_tiers": []
                },
                {
                    "id": 11,
                    "price_tiers": []
                },
                {
                    "id": 12,
                    "price_tiers": []
                },
                {
                    "id": 6,
                    "price_tiers": []
                },
                {
                    "id": 3,
                    "price_tiers": []
                },
                {
                    "id": 41,
                    "price_tiers": []
                },
                {
                    "id": 18,
                    "price_tiers": []
                },
                {
                    "id": 39,
                    "price_tiers": []
                },
                {
                    "id": 17,
                    "price_tiers": []
                },
                {
                    "id": 1,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 23,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 19,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 8,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 13,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 15,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 16,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 22,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 43,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                },
                {
                    "id": 44,
                    "price_tiers": [
                        {
                            "quantity": 1,
                            "final_price": {
                                "value": 34
                            }
                        },
                        {
                            "quantity": 5,
                            "final_price": {
                                "value": 32
                            }
                        }
                    ]
                }
            >
        }
    }
}
  1. The issue started happening since commit b2021d5#diff-8d1c1372668a97ccd40b222f73acfe4c6b5ce24ad261215306610ae8817cdc65

cc: @Usik2203

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • <x] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ > Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions