inventory icon indicating copy to clipboard operation
inventory copied to clipboard

New Module to enable MSI for Configurable Product GraphQl

Open bordeo opened this issue 4 years ago • 1 comments

New Module to enable MSI for Configurable Product GraphQl

Description

Added a new module to enable MSI for Configurable Product GraphQl. The Magento_InventoryConfigurableProduct module is overriding the Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder plugin, but no module is overriding the Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder_GraphQl plugin. This new module solves the issue.

Fixed Issues

Using graphql to read a configurable product options leads to have an empty array of option values. This happens because the Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder_GraphQl plugin uses a SQL query joining the module-catalog-inventory tables instead the module-inventory tables.

Manual testing scenarios

  1. Create a new inventory source
  2. Create a new inventory stock associated with websites and the new inventory source
  3. Create Configurable Product and variants
  4. Create new “in stock” Source Items on the new Inventory Source for the product variants
    image
  5. Remove Default Source Items
  6. Run graphql
query getProductDetailForProductPage($urlKey: String!) {
  products(filter: { url_key: { eq: $urlKey } }) {
    items {
      id
      ... on ConfigurableProduct {
        configurable_options {
          attribute_code
          attribute_id
          id
          label
          values {
            default_label
            label
            store_label
            use_default_value
            value_index
            swatch_data {
              ... on ImageSwatchData {
                thumbnail
              }
              value
            }
          }
        }
      }
    }
  }
}
  1. products.items.configurable_options.values should return an array of values

Contribution checklist

  • [ ] Pull request has a meaningful description of its purpose
  • [ ] All commits are accompanied by meaningful commit messages
  • [ ] All new or changed code is covered with unit/integration tests (if applicable)
  • [ ] All automated tests passed successfully (all builds are green)

bordeo avatar Mar 13 '21 12:03 bordeo

@magento run all tests

sidolov avatar Mar 17 '21 15:03 sidolov