Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento REST API : Configurable product with product links provided: "same set of attribute values" error #39534

Open
1 of 5 tasks
JoryHogeveen opened this issue Jan 10, 2025 · 10 comments
Labels
Area: Catalog Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@JoryHogeveen
Copy link

JoryHogeveen commented Jan 10, 2025

Preconditions and environment

  • Magento version: 2.4.7-p3
  • Anything else that would help a developer reproduce the bug

Steps to reproduce

To be honest, I'm not sure how to reproduce this properly. There are cases where this happens and there are cases where it doesn't.

There are two related topics, both resulted in no further actions even though there are definitely cases where this occurs:
#33937
#16349

In my case I'm using the REST API to provide the linked product ID's.
The products that run into errors are validated several times and I can 100% confirm that these use different attribute values.
I also verified that the attribute value ID's are not even remotely similar (eg. 1456 vs 65 etc.) so some string comparison bug couldn't really be the issue here.

Another possibly important thing to note here is that the configurable product I tested against already exists in Magento.
Also, all these children (product links) are already linked to this product as well!

This REST API call is done in a loop which combines many product updates which could by anything. In this case there is no real change in the product links but since it's part of the update it is still send.

EDIT: Also not that when I add the child products manually through the Magento Admin interface I do not get the same error!

EDIT 2: I also verified the actual product results through the REST API and confirmed the attribute value IDs are not the same.

Expected result

Created product with links between parent and children products without exception.

Actual result

Got an exception, example:

"{"message":"Products \"%1\" and \"%2\" have the same set of attribute values.","parameters":[3155,3172]}"

Note:
Product 3155 has attribute value ID "1487"
Product 3172 has attribute value ID "45"

Additional information

Not sure if this would be relevant but these attributes have a LOT of option values, like about 500 options to choose from.
There are several other attributes as well (not used for configurations though) so the total number of attribute option IDs from different attributes is about 2000.

Release note

I've marked this as S0 since there is currently no way of going around this. It's simply not updating.

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.
  • 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”.
Copy link

m2-assistant bot commented Jan 10, 2025

Hi @JoryHogeveen. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@JoryHogeveen
Copy link
Author

I've done some digging in the code and what happens in the response and I think I've found the issue.

It seems that the contents of $attributeCodes was empty in Magento\ConfigurableProduct\Model\Plugin\ProductRepositorySave::validateProductLinks().

Note that I did not pass the configurable_product_options array since this product already exists and is configured. This is also not a required parameter according to docs. However, from what I can find so far, it appears that the REST API enforces you to pass this information otherwise it's empty and not automatically fetched from the current product config in ProductRepositorySave::beforeSave().

I verified this behavior by adjusting my API call to always include the config and yep, the update now works!

Of course I might have misinterpreted the documentation, but I was under the impression that you only need to produce the options when creating a configurable product, not when updating,
In case of updating, shouldn't it use the currently configured product options if this is not provided in the API request?

Hopefully somebody can provide some more insights on the inner workings of these endpoints.

Since there now is a workaround, I've changed the severity to S1

@engcom-Bravo engcom-Bravo added the Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. label Jan 13, 2025
@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Jan 13, 2025
@engcom-Hotel engcom-Hotel self-assigned this Jan 13, 2025
Copy link

m2-assistant bot commented Jan 13, 2025

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @JoryHogeveen,

Thanks for the report and collaboration!

We request you to please provide the rest API for which you are facing this issue.

Thanks

@engcom-Hotel engcom-Hotel added the Issue: needs update Additional information is require, waiting for response label Jan 13, 2025
@engcom-Hotel engcom-Hotel moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jan 13, 2025
@JoryHogeveen
Copy link
Author

JoryHogeveen commented Jan 13, 2025

Hi @engcom-Hotel

I was using the main /products endpoint which includes the configurable_product_links under the extension_attributes request param.

Please also read my latest comment in where I've found the actual cause.

Steps:

  1. Create a configurable product through the API (or admin, I don't think this would matter).
  2. Make sure to add some child products and configure a configurable option.
  3. Use the same API endpoint products to update the configurable product, this time do not include configurable_product_options but only add the child products in configurable_product_links.

Example for the second update call:

{
    "product": {
        "sku": "Your sku",
        "extension_attributes": {
            "configurable_product_links": [
                child_product_id_1,
                child_product_id_2,
                child_product_id_3
            ]
        }
    }
}

Since the configurable option is already made at this point I would assume that Magento would autofill in the new attribute values from the product links. However, this does not happen. Instead, you are required to provide the whole configurable_product_options configuration within the API call.

The reason I assume that this would not be needed is because of three reasons:

  1. The configurable_product_options is not required and it's not mentioned anywhere that it is required when updating a configurable product.
  2. The configurable_product_links is a separate parameter from the above options and therefore should behave autonomously.
  3. There are also other endpoints for configurable products in which you can just pass the SKU and it will be added to the product links automatically. See endpoint /configurable-product/{sku}/child for example.

Please let me know your thoughts about my assessment here.
And thank you for looking into this!

@engcom-Hotel
Copy link
Contributor

Hello @JoryHogeveen,

Thanks for the response!

We have tried to reproduce the issue in the latest 2.4-develop branch but the issue is not reproducible for us. We have followed the below dev docs to create the configurable product through the rest API:

https://developer.adobe.com/commerce/webapi/rest/tutorials/configurable-product/

We can create products successfully. Please let us know if we missed anything.

Thanks

@JoryHogeveen
Copy link
Author

JoryHogeveen commented Jan 17, 2025

Hi @engcom-Hotel

Thank you for your reply!
That tutorial is only for creating a configurable product, which indeed works fine.
Could you also test updating the same product the way I described above? (Omitting the configurable_product_options key).

I could reproduce this consistently but case you still cannot reproduce: I'm on my phone right now and will revisit this when I'm back from holiday at the end of this month.

Thank you!

@engcom-Hotel
Copy link
Contributor

Hello @JoryHogeveen,

Thanks for the reply!

We have tried to update the same configurable product via the below endpoint:

rest/all/V1/products/MS-Champ
with the below payload:

{
  "product": {
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 4,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "weight": "500",
    "extension_attributes": {
        "configurable_product_links": [
          30, 31
        ]
    }
  }
}

And we can reproduce the issue. Please refer to the below screenshot for reference:

Image

Hence we are confirming the issue. I suggest you to create a community PR with the fix of this issue. We will be happy to process it further.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P3 May be fixed according to the position in the backlog. Area: Catalog and removed Issue: needs update Additional information is require, waiting for response labels Jan 20, 2025
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-13742 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Jan 20, 2025

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

No branches or pull requests

4 participants