magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Internal server error while getting a category that contains grouped products without child products #38665

Closed rdk-pmis closed 5 months ago

rdk-pmis commented 6 months ago

Preconditions and environment

Steps to reproduce

Make sure that there are simple products that aren't linked to the second website. Now create a grouped product in the default store view, link this to both store views and add child products that are only linked to the first website Link the product to categories of both websites. Add simple products to the same categories. Now query the category using graphql and set the value for store in the headers to the code of a store view from the second website Now do the following query (replace the value of category_id with the id of the category from the second website you've chosen for your grouped product:

{ products(pageSize: 12 currentPage: 1 filter: {category_id: {eq: "42"} } ) { total_count page_info { page_size current_page total_pages } aggregations {  attribute_code count label options { count label value } }  items { sku description {html} price_range{maximum_price {
    discount {
      amount_off
      percent_off
    }
    final_price {
      currency
      value
    }
    fixed_product_taxes {
      amount {currency value}
      label
    }
    regular_price {
      currency
      value
    }
  }minimum_price {
    discount {
      amount_off
      percent_off
    }
    final_price {
      currency
      value
    }
    fixed_product_taxes {
      amount{currency value}
      label
    }
    regular_price {
      currency
      value
    }
  }}}}}

Result is an internal server error in the errors section When I check the exception log I get: {"exception":"[object] (GraphQL\\Error\\Error(code: 0): Warning: Trying to access array offset on value of type null in /app/vendor/magento/module-grouped-product-graph-ql/Model/Resolver/Product/Price/Provider.php on line 95 at /app/vendor/webonyx/graphql-php/src/Error/Error.php:155) [previous exception] [object] (Exception(code: 0): Warning: Trying to access array offset on value of type null in /app/vendor/magento/module-grouped-product-graph-ql/Model/Resolver/Product/Price/Provider.php on line 95 at /app/vendor/magento/framework/App/ErrorHandler.php:62)"}

Expected result

No errors

Actual result

{
  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 1,
          "column": 247
        }
      ],
      "path": [
        "products",
        "items",
        0,
        "price_range"
      ]
    }
  ],
  "data": {
    "products": {
      "total_count": 4,
      "page_info": {
        "page_size": 12,
        "current_page": 1,
        "total_pages": 1
      },
      "aggregations": [
        {
          "attribute_code": "price",
          "count": 2,
          "label": "Price",
          "options": [
            {
              "count": 2,
              "label": "40-50",
              "value": "40_50"
            },
            {
              "count": 1,
              "label": "50-60",
              "value": "50_60"
            }
          ]
        },
        {
          "attribute_code": "category_uid",
          "count": 1,
          "label": "Category",
          "options": [
            {
              "count": 4,
              "label": "Child",
              "value": "NDI="
            }
          ]
        },
        {
          "attribute_code": "activity",
          "count": 12,
          "label": "Activity",
          "options": [
            {
              "count": 1,
              "label": "Outdoor",
              "value": "5"
            },
            {
              "count": 1,
              "label": "Yoga",
              "value": "8"
            },
            {
              "count": 3,
              "label": "Recreation",
              "value": "9"
            },
            {
              "count": 2,
              "label": "Gym",
              "value": "11"
            },
            {
              "count": 1,
              "label": "Athletic",
              "value": "16"
            },
            {
              "count": 1,
              "label": "Sports",
              "value": "17"
            },
            {
              "count": 1,
              "label": "Hiking",
              "value": "18"
            },
            {
              "count": 1,
              "label": "Overnight",
              "value": "19"
            },
            {
              "count": 1,
              "label": "School",
              "value": "20"
            },
            {
              "count": 1,
              "label": "Trail",
              "value": "21"
            },
            {
              "count": 1,
              "label": "Travel",
              "value": "22"
            },
            {
              "count": 1,
              "label": "Urban",
              "value": "23"
            }
          ]
        },
        {
          "attribute_code": "category_gear",
          "count": 4,
          "label": "Category Gear",
          "options": [
            {
              "count": 3,
              "label": "Electronic",
              "value": "86"
            },
            {
              "count": 2,
              "label": "Exercise",
              "value": "87"
            },
            {
              "count": 1,
              "label": "Fashion",
              "value": "88"
            },
            {
              "count": 3,
              "label": "Timepiece",
              "value": "90"
            }
          ]
        },
        {
          "attribute_code": "eco_collection",
          "count": 1,
          "label": "Eco Collection",
          "options": [
            {
              "count": 2,
              "label": "No",
              "value": "0"
            }
          ]
        },
        {
          "attribute_code": "erin_recommends",
          "count": 2,
          "label": "Erin Recommends",
          "options": [
            {
              "count": 2,
              "label": "No",
              "value": "0"
            },
            {
              "count": 1,
              "label": "Yes",
              "value": "1"
            }
          ]
        },
        {
          "attribute_code": "features_bags",
          "count": 8,
          "label": "Features",
          "options": [
            {
              "count": 1,
              "label": "Hydration Pocket",
              "value": "71"
            },
            {
              "count": 1,
              "label": "Audio Pocket",
              "value": "72"
            },
            {
              "count": 1,
              "label": "Flapover",
              "value": "73"
            },
            {
              "count": 1,
              "label": "Waterproof",
              "value": "74"
            },
            {
              "count": 1,
              "label": "Lightweight",
              "value": "75"
            },
            {
              "count": 1,
              "label": "Reflective",
              "value": "77"
            },
            {
              "count": 1,
              "label": "Laptop Sleeve",
              "value": "78"
            },
            {
              "count": 1,
              "label": "Lockable",
              "value": "79"
            }
          ]
        },
        {
          "attribute_code": "gender",
          "count": 2,
          "label": "Gender",
          "options": [
            {
              "count": 0,
              "label": "Male",
              "value": "1"
            },
            {
              "count": 3,
              "label": "Women",
              "value": "81"
            }
          ]
        },
        {
          "attribute_code": "material",
          "count": 12,
          "label": "Material",
          "options": [
            {
              "count": 1,
              "label": "Burlap",
              "value": "31"
            },
            {
              "count": 1,
              "label": "Canvas",
              "value": "32"
            },
            {
              "count": 1,
              "label": "Cotton",
              "value": "33"
            },
            {
              "count": 1,
              "label": "Leather",
              "value": "35"
            },
            {
              "count": 1,
              "label": "Mesh",
              "value": "36"
            },
            {
              "count": 1,
              "label": "Nylon",
              "value": "37"
            },
            {
              "count": 1,
              "label": "Polyester",
              "value": "38"
            },
            {
              "count": 1,
              "label": "Suede",
              "value": "41"
            },
            {
              "count": 1,
              "label": "Plastic",
              "value": "44"
            },
            {
              "count": 1,
              "label": "Rubber",
              "value": "45"
            },
            {
              "count": 1,
              "label": "Stainless Steel",
              "value": "47"
            },
            {
              "count": 2,
              "label": "Silicone",
              "value": "48"
            }
          ]
        },
        {
          "attribute_code": "new",
          "count": 2,
          "label": "New",
          "options": [
            {
              "count": 2,
              "label": "No",
              "value": "0"
            },
            {
              "count": 1,
              "label": "Yes",
              "value": "1"
            }
          ]
        },
        {
          "attribute_code": "performance_fabric",
          "count": 1,
          "label": "Performance Fabric",
          "options": [
            {
              "count": 2,
              "label": "No",
              "value": "0"
            }
          ]
        },
        {
          "attribute_code": "sale",
          "count": 2,
          "label": "Sale",
          "options": [
            {
              "count": 2,
              "label": "No",
              "value": "0"
            },
            {
              "count": 3,
              "label": "Yes",
              "value": "1"
            }
          ]
        },
        {
          "attribute_code": "strap_bags",
          "count": 7,
          "label": "Strap/Handle",
          "options": [
            {
              "count": 1,
              "label": "Adjustable",
              "value": "61"
            },
            {
              "count": 1,
              "label": "Cross Body",
              "value": "62"
            },
            {
              "count": 1,
              "label": "Detachable",
              "value": "63"
            },
            {
              "count": 1,
              "label": "Double",
              "value": "64"
            },
            {
              "count": 1,
              "label": "Padded",
              "value": "65"
            },
            {
              "count": 1,
              "label": "Shoulder",
              "value": "66"
            },
            {
              "count": 1,
              "label": "Single",
              "value": "67"
            }
          ]
        },
        {
          "attribute_code": "style_bags",
          "count": 5,
          "label": "Style Bags",
          "options": [
            {
              "count": 1,
              "label": "Backpack",
              "value": "24"
            },
            {
              "count": 1,
              "label": "Messenger",
              "value": "27"
            },
            {
              "count": 1,
              "label": "Laptop",
              "value": "28"
            },
            {
              "count": 1,
              "label": "Exercise",
              "value": "29"
            },
            {
              "count": 1,
              "label": "Tote",
              "value": "30"
            }
          ]
        }
      ],
      "items": [
        null,
        {
          "sku": "24-WG03",
          "description": {
            "html": "<p>Keep track of time on the treadmill or trail with our Clamber Watch. The flexible, rubberized strap is contoured to conform to your wrist for a comfortable fit all day. The face features an illuminated digital read-out of the current time and stopwatch functions.</p>\r\n<ul>\r\n<li>Japanese quartz movement.</li>\r\n<li>Strap fits 5\" to 6.0\".</li>\r\n</ul>"
          },
          "price_range": {
            "maximum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 54
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 54
              }
            },
            "minimum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 54
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 54
              }
            }
          }
        },
        {
          "sku": "24-WG01",
          "description": {
            "html": "<p>The Bolo Sport Watch is sleek, sporty and sized just right to fit your smaller wrist. Easy to read and set up, it features a large digital face and button-activated alarm and stopwatch. The soft-touch resin band promises no-pinch comfort, while the water-resistant design lets you take your workout to the lap pool.</p>\n<ul>\n<li>Displays time, day and date.</li>\n<li>Two-tone design.</li>\n<li>12/24 hour formats.</li>\n<li>Nickel-free buckle on band.</li>\n<li>Battery included.</li>\n</ul>"
          },
          "price_range": {
            "maximum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 49
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 49
              }
            },
            "minimum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 49
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 49
              }
            }
          }
        },
        {
          "sku": "24-WG09",
          "description": {
            "html": "<p>Designed to stand up to your active lifestyle, this women's Luma Analog Watch features a tasteful brushed chrome finish and a stainless steel, water-resistant construction for lasting durability.</p>\n<ul>\n<li>Precision Miyota&reg; three-hand movement.</li>\n</ul>"
          },
          "price_range": {
            "maximum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 43
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 43
              }
            },
            "minimum_price": {
              "discount": {
                "amount_off": 0,
                "percent_off": 0
              },
              "final_price": {
                "currency": "EUR",
                "value": 43
              },
              "fixed_product_taxes": [],
              "regular_price": {
                "currency": "EUR",
                "value": 43
              }
            }
          }
        }
      ]
    }
  }
}

Additional information

name : magento/module-grouped-product-graph-ql descrip. : N/A keywords : versions : * 100.4.7 type : magento2-module license : Open Software License 3.0 (OSL-3.0) (OSI approved) https://spdx.org/licenses/OSL-3.0.html#licenseText license : Academic Free License v3.0 (AFL-3.0) (OSI approved) https://spdx.org/licenses/AFL-3.0.html#licenseText homepage : source : []
dist : [zip] https://repo.magento.com/archives/magento/module-grouped-product-graph-ql/magento-module-grouped-product-graph-ql-100.4.7.0.zip path : /media/disk2/dev/magento2/magento24/src/vendor/magento/module-grouped-product-graph-ql names : magento/module-grouped-product-graph-ql

autoload files psr-4 Magento\GroupedProductGraphQl\ => .

requires magento/framework 103.0. magento/module-catalog 104.0. magento/module-catalog-graph-ql 100.4. magento/module-grouped-product 100.4. php ~8.1.0||~8.2.0||~8.3.0

Default storeview image

view 2 image

Category: image

Release note

No response

Triage and priority

m2-assistant[bot] commented 6 months ago

Hi @rdk-pmis. 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. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 6 months ago

Hi @engcom-Delta. 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: :point_down:

engcom-Delta commented 6 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 6 months ago

Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 6 months ago

Hi @engcom-Delta, here is your Magento Instance: https://4aa86b70ffcff9afc88ee121b9e65060.instances-prod.magento-community.engineering Admin access: https://4aa86b70ffcff9afc88ee121b9e65060.instances-prod.magento-community.engineering/admin_daab Login: 6bff81b6 Password: 2aee3fd01226

engcom-Delta commented 6 months ago

Hi @rdk-pmis,

Verified the issue on 2.4-develop and 2.4.7 and it is not reproducible.

Steps to reproduce:-

1.Make sure that there are simple products that aren't linked to the second website. 2.Now create a grouped product in the default store view, link this to both store views and add child products that are only linked to the first website 3.Link the product to categories of both websites. 4.Add simple products to the same categories. 5.Now query the category using graphql and set the value for store in the headers to the code of a store view from the second website 6.Now do the following query (replace the value of category_id with the id of the category from the second website you've chosen for your grouped product:

Please refer the attached screenshot and let us if we are missing something.

Multiple website created other than default like test1

Screenshot 2024-05-10 at 9 33 32 PM

Grouped product created in default store view

Screenshot 2024-05-10 at 9 34 00 PM

Child products are added which are only in default website

Screenshot 2024-05-10 at 9 34 16 PM

Grouped product added to all websites

Screenshot 2024-05-10 at 9 34 25 PM

Products in the category

Screenshot 2024-05-10 at 9 36 23 PM

hit the given graphql query and no internal server error recorded

Screenshot 2024-05-10 at 9 36 52 PM
engcom-Delta commented 5 months ago

Hi @rdk-pmis,

Awaiting your reply on this issue to move further.

Thanks,

engcom-Delta commented 5 months ago

Hello @rdk-pmis ,

As there is no activity on this issue for a long time, we believe the issue has been resolved, hence closing this issue. Feel free to raise a new issue or reopen this if you need more assistance.

Thanks,