MDVA-37748:GraphQL查询返回未分配给共享目录的产品

MDVA-37748修补程序修复了GraphQL查询返回未分配给共享目录的产品的问题。 安装Quality Patches Tool (QPT) 1.1.5时,此修补程序可用。 修补程序ID为MDVA-37748。 请注意,该问题计划在Adobe Commerce 2.4.4中修复。

受影响的产品和版本

为Adobe Commerce版本创建了修补程序:

Adobe Commerce(所有部署方法) 2.4.2

与Adobe Commerce版本兼容:

Adobe Commerce(所有部署方法) 2.4.2 - 2.4.2-p2

NOTE
该修补程序可能适用于具有新的Quality Patches Tool版本的其他版本。 要检查修补程序是否与您的Adobe Commerce版本兼容,请将magento/quality-patches包更新到最新版本,并在Quality Patches Tool:搜索修补程序页面上检查兼容性。 使用修补程序ID作为搜索关键字来查找修补程序。

问题

GraphQL查询返回未分配给共享目录的产品。

先决条件

已安装B2B模块。

重现步骤

  1. 创建两个产品并将它们分配给一个类别:

    • 产品1 — 公共
    • 产品2
  2. 将“Product 1 - Public”分配给“Default (General)”共享目录。

  3. 创建一个额外的自定义共享目录,并将其分配给“产品2”。

  4. 创建一个新公司,并将其分配给在步骤3中创建的其他共享目录。

  5. 在cron执行/重新索引后,在前端验证您是否能在未登录的情况下看到“产品1 — 公共”。

  6. 以步骤4中创建的公司的管理员身份登录,验证您是否只看到“Product 2”。

  7. 使用以下GraphQL查询请求授权令牌:

    code language-graphql
    
     mutation {
       generateCustomerToken(
         email: "company.admin@exapmle.test"
         password: "password"
       ) {
         token
       }
     }
    
    
  8. 添加标头​ Authorization Bearer value-of-the-token ​并执行以下GraphQL查询:

    code language-graphql
    
     {
       products(
           filter: {},
           pageSize: 100,
           currentPage: 1
           sort: {}
         ) {
           total_count
           page_info {
             page_size
             current_page
           }
           aggregations {
             attribute_code
             count
             label
             options {
               label
               value
               count
             }
           }
           items {
             name
             sku
             created_at
             updated_at
             stock_status
             description {html}
             short_description {html}
             url_key
             url_path
             price_tiers{
               final_price{
                   value
                   currency
                 }
               discount{
                   amount_off
                   percent_off
                 }
               quantity
             }
             price_range {
              maximum_price {
               regular_price {
                 value
               }
               final_price {
                 value
               }
             }
             minimum_price {
               regular_price {
                 value
               }
               final_price {
                value
               }
             }
           }
           image {
            url
           }
           thumbnail {
            url
           }
           small_image {
            url
           }
           media_gallery {
            url
           }
           ... on ConfigurableProduct {
             configurable_options {
              id
    
          label
          position
          use_default
          attribute_code
          values {
            value_index
            label
            swatch_data {
              value
            }
         }
         product_id
       }
       variants {
         product {
           id
           name
           sku
           ​#margin
           ​#margin_percentage
           image {
             url
           }
           small_image {
             url
           }
           thumbnail {
             url
           }
           media_gallery{
             url
           }
           attribute_set_id
           ... on PhysicalProductInterface {
             weight
           }
           price_range {
             minimum_price {
               regular_price {
                 value
                 currency
               }
             }
           }
         }
         attributes {
           label
           code
           value_index
         }
       }
     }
    
    
    
    
    }
    

预期的结果

GraphQL返回的计数和产品仅考虑分配给与登录用户关联的共享目录的产品。

实际结果

只返回“Product 2”,但total_count显示两个。


{
  "data": {
    "products": {
      "total_count": 2,
      "page_info": {
        "page_size": 100,
        "current_page": 1
      },
      "aggregations": [
        {
          "attribute_code": "price",
          "count": 2,
          "label": "Price",
          "options": [
            {
              "label": "0-100",
              "value": "0_100",
              "count": 1
            },
            {
              "label": "100-200",
              "value": "100_200",
              "count": 1
            }
          ]
        },
        {
          "attribute_code": "category_id",
          "count": 1,
          "label": "Category",
          "options": [
            {
              "label": "Cat 1",
              "value": "3",
              "count": 2
            }
          ]
        }
      ],
      "items": [
        {
          "name": "Product 2",
          "sku": "Product 2",
          "created_at": "2021-05-12 10:51:44",
          "updated_at": "2021-05-12 11:03:24",
          "stock_status": "IN_STOCK",
          "description": {
            "html": ""
          },
          "short_description": {
            "html": ""
          },
          "url_key": "product-2",
          "url_path": null,
          "price_tiers": [
            {
              "final_price": {
                "value": 90,
                "currency": "USD"
              },
              "discount": {
                "amount_off": 10,
                "percent_off": 10
              },
              "quantity": 1
            }
          ],
          "price_range": {
            "maximum_price": {
              "regular_price": {
                "value": 100
              },
              "final_price": {
                "value": 90
              }
            },
            "minimum_price": {
              "regular_price": {
                "value": 100
              },
              "final_price": {
                "value": 90
              }
            }
          },
          "image": {
            "url": "../pub/static/version1620816308/frontend/Magento/luma/en_US/Magento_Catalog/images/product/placeholder/image.jpg"
          },
          "thumbnail": {
            "url": "../pub/static/version1620816308/frontend/Magento/luma/en_US/Magento_Catalog/images/product/placeholder/thumbnail.jpg"
          },
          "small_image": {
            "url": "../pub/static/version1620816308/frontend/Magento/luma/en_US/Magento_Catalog/images/product/placeholder/small_image.jpg"
          },
          "media_gallery": []
        }
      ]
    }
  }
}

应用修补程序

要应用单独的修补程序,请根据您的部署方法使用以下链接:

相关阅读

要了解有关Quality Patches Tool的更多信息,请参阅:

有关QPT中其他可用修补程序的信息,请参阅QPT🔗中可用的修补程序部分。

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a