magento / devdocs

Magento Developer Documentation
https://devdocs.magento.com
Open Software License 3.0
673 stars 1.77k forks source link

docs(graphql): ConfigurableProductOptions.use_default is documented incorrectly #9526

Open engcom-November opened 1 year ago

engcom-November commented 1 year ago

Is there an existing issue for this?

Which topic?

https://devdocs.magento.com/guides/v2.4/graphql/interfaces/configurable-product.html

What's wrong with the content?

use_default: Boolean @doc(description: "Indicates whether the option is the default.") This doc is incorrect and unclear

What changes do you propose?

Change the doc to read more similarly to ConfigurableProductOptionsValues.use_default_value (the real purpose of the node).

use_default_value: Boolean @doc(description: "Indicates whether to use the default_label.") As that's the actual purpose of the flag.

Anything else that can help to cover this?

No response

m2-assistant[bot] commented 1 year ago

Hi @engcom-November. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


keharper commented 1 year ago

@damienwebdev If you have any idea what this field really does, leave a message here. It's going to be difficult to find an internal developer who knows.

damienwebdev commented 1 year ago
type ConfigurableProductOptions @doc(description: "Defines configurable attributes for the specified product.") {
    use_default: Boolean @doc(description: "Indicates whether the option is the default.")
}

type ConfigurableProductOptionsValues @doc(description: "Contains the index number assigned to a configurable product option.") {
    use_default_value: Boolean @doc(description: "Indicates whether to use the default_label.")
}

I'm pretty sure (not 100%) that these two values are similar in intent, but at different levels (attribute vs. attribute value). I think they refer to the fallback mechanism for configurable attribute labels across:

  1. Product Specific Scope
  2. Store Scope
  3. Root Scope

Consider the following attribute structure:

{
  "code": "test_attribute",
  "label": "Test Attribute",
  "use_default": false
  "values": [
    {
      "uid": "1",
      "label": "Green"
      "store_label": "Green", 
      "default_label": "Some better name but specific to this product",
      "use_default_value": false
    }
  ]
}

In reality, the behind the scenes data structure looks like:

{
  code: "test_attribute",
  label: "Test Attribute",
  store_label: "Test Store Attribute", 
  default_label: "Test Product Attribute Name at Store Level",
  use_default: false
  values: [
    {
      uid: "1",
      label: "Green"
      store_label: "Green", 
      default_label: "Some better name but specific to this product",
      use_default_value: false
    }
  ]
}

I believe (unfortunately) that GraphQl is over-exposing the values: on ConfigurableProductOptionsValues

ConfigurableProductOptionsValues {
   store_label: "Green", <-- Not relevant
   default_label: "Some better name but specific to this product" <-- Not relevant
   use_default_value: false <-- Not relevant
}

ConfigurableProductOptions { 
  label: "Test Attribute",
  store_label: "Some other language",  <-- Not relevant
  default_label: "Some better name but specific to this product", <-- Not relevant
  use_default: false <-- Not relevant
}