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

IsEnabledOptionSelectBuilder does not take store value into account #3410

Open
aligent-lturner opened this issue Jun 12, 2024 · 1 comment
Open

Comments

@aligent-lturner
Copy link

Preconditions (*)

  1. Magento Inventory 1.2.7, 1.2.7-p1

Steps to reproduce (*)

  1. Create a configurable product with colour and size as configurable options.
  2. Create simple variants for colours Red, Purple and Black, sizes XS, S, M, L and XL
  3. Disable all variants with size XS at global level
  4. Enable the same variants at the store level

Expected result (*)

  1. A graphql call returning configurable_options should include XS as a size value
query {
  products(
    search: "teton"
  ){
    items {
      sku
      ... on ConfigurableProduct {
        configurable_options {
          attribute_code
          label
          values {
            label
          }
        }
        variants {
          product {
            sku
          }
        }
      }
    }
  }
}
{
  "data": {
    "products": {
      "items": [
        {
          "sku": "MH02",
          "configurable_options": [
            {
              "attribute_code": "color",
              "label": "Color",
              "values": [
                {
                  "label": "Black"
                },
                {
                  "label": "Purple"
                },
                {
                  "label": "Red"
                }
              ]
            },
            {
              "attribute_code": "size",
              "label": "Size",
              "values": [
                {
                  "label": "XS"
                },
                {
                  "label": "S"
                },
                {
                  "label": "M"
                },
                {
                  "label": "L"
                },
                {
                  "label": "XL"
                }
              ]
            }
          ],
          "variants": [
            {
              "product": {
                "sku": "MH02-XS-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-XS-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-XS-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Red"
              }
            }
          ]
        }
      ]
    }

Actual result (*)

  1. XS is not returned as a size value:
{
  "data": {
    "products": {
      "items": [
        {
          "sku": "MH02",
          "configurable_options": [
            {
              "attribute_code": "color",
              "label": "Color",
              "values": [
                {
                  "label": "Black"
                },
                {
                  "label": "Purple"
                },
                {
                  "label": "Red"
                }
              ]
            },
            {
              "attribute_code": "size",
              "label": "Size",
              "values": [
                {
                  "label": "S"
                },
                {
                  "label": "M"
                },
                {
                  "label": "L"
                },
                {
                  "label": "XL"
                }
              ]
            }
          ],
          "variants": [
            {
              "product": {
                "sku": "MH02-XS-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-XS-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-XS-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-S-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-M-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-L-Red"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Black"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Purple"
              }
            },
            {
              "product": {
                "sku": "MH02-XL-Red"
              }
            }
          ]
        }
      ]
    }

The cause of the issue is the order variables are passed into the getIfNullSql function here -

$select->getConnection()->getIfNullSql('entity_status_global.value', 'entity_status_store.value') . ' = ?',

The global value is passed first, meaning that the store value is only used if the global value is null (which should never be the case). These should be swapped - the store value should be used, and if it is null, the global value should be used instead.

Copy link

m2-assistant bot commented Jun 12, 2024

Hi @aligent-lturner. 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


Join Magento Community Engineering Slack and ask your questions in #github channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Grooming
Development

No branches or pull requests

1 participant