magento / magento/magento2

[GraphQl] Bundle Product with fixed price, bundle option products prices are not scoped

Open
#39,149 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: APIs Component: Api Issue: Confirmed Priority: P3 Progress: ready for dev Reported on 2.4.7-p2 Reproduced on 2.4.x
Dominant language
PHP
Stars
12.2k
Forks
9.4k
PR merge metrics
No merged PRs in 30d

Description

### Preconditions and environment

- Magento 2.4.7-p2
- Multistore (multiple websites with different currencies)
- Price attribute set to 'website' scope

### Steps to reproduce

Steps with example screenshots:

1. Switch to ALL STORE VIEWS
2. Create new bundle product. Set 'dynamic price' to OFF (set price to fixed). Proceed with normal product creation (fill prices etc):
![obraz](https://github.com/user-attachments/assets/b32bf870-78fd-45d0-a1bb-03858343722f)
3. Add new bundle option. Fill required fields and set fixed price:
![obraz](https://github.com/user-attachments/assets/b02cb147-12a8-43a8-b439-7ac473b5e8f8)
5. Switch scope to different website, edit product option and set different fixed price:
![obraz](https://github.com/user-attachments/assets/b4a97aa4-102a-46bb-9a60-d92a90438554)
6. Check product data via GraphQl

Summary of my example:

ALL STORE VIEWS:
Product price: 1000
Product option price: 111

XXX STORE VIEW:
Product price: Inherit from ALL STORE VIEWS - 1000
Product option price: 333

GraphQL query used to test:
```query testProductDetails {
products(filter: { sku: { eq: "test_bundle_product_sku" } }) {
items {
... on BundleProduct{
dynamic_price
price_range {
minimum_price {
final_price {
value
}
}
maximum_price {
final_price {
value
}
}
}
price_details {
discount_percentage
main_final_price
main_price
__typename
}
items {
uid
required
title
options {
uid
is_default
price
price_type
quantity
__typename
}
__typename
}
}
__typename
}
__typename
}
}
```

### Expected result

GraphQl query should provide correct prices for both product and its item options.

```
{
"data": {
"products": {
"items": [
{
"dynamic_price": false,
"price_range": {
"minimum_price": {
"final_price": {
"value": 1333
}
},
"maximum_price": {
"final_price": {
"value": 1333
}
}
},
"price_details": {
"discount_percentage": 0,
"main_final_price": 1000,
"main_price": 1000,
"__typename": "PriceDetails"
},
"items": [
{
"uid": "YnVuZGxlLzQ=",
"required": true,
"title": "bbb",
"options": [
{
"uid": "YnVuZGxlLzQvNC8x",
"is_default": false,
"price": 333,
"price_type": "FIXED",
"quantity": 1,
"__typename": "BundleItemOption"
}
],
"__typename": "BundleItem"
}
],
"__typename": "BundleProduct"
}
],
"__typename": "Products"
}
}
}
```

### Actual result

Product price is calculated correctly (BASE 1000 + OPTION 333 = minimum and maximum final price is 1333)
Product item option price is incorrectly returned 111 instead of 333. This breaks all frontend calculations for this configuration

```
{
"data": {
"products": {
"items": [
{
"dynamic_price": false,
"price_range": {
"minimum_price": {
"final_price": {
"value": 1333
}
},
"maximum_price": {
"final_price": {
"value": 1333
}
}
},
"price_details": {
"discount_percentage": 0,
"main_final_price": 1000,
"main_price": 1000,
"__typename": "PriceDetails"
},
"items": [
{
"uid": "YnVuZGxlLzQ=",
"required": true,
"title": "bbb",
"options": [
{
"uid": "YnVuZGxlLzQvNC8x",
"is_default": false,
"price": 111,
"price_type": "FIXED",
"quantity": 1,
"__typename": "BundleItemOption"
}
],
"__typename": "BundleItem"
}
],
"__typename": "BundleProduct"
}
],
"__typename": "Products"
}
}
}
```

### Additional information

This happens because implementation in \Magento\BundleGraphQl\Model\Resolver\Links\Collection::fetch. Link collection does not join "catalog_product_bundle_selection_price" table in any way, only providing base (all store views) data from "catalog_product_bundle_selection" table.

### Release note

_No response_

### Triage and priority

- [ ] 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._
- [X] 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”._

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Magento\BundleGraphQl\Model\Resolver\Links\Collection::fetch and compare the link collection with the catalog_product_bundle_selection_price table. Reproduce the provided GraphQL query across the two website scopes, then verify that the returned bundle option price matches the selected website price while the existing product totals remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.