Skip to content

GraphQL Product Visibility #35086

Open
Open
@DanieliMi

Description

@DanieliMi

Summary (*)

I am wondering about the $isChildSearch parameter here it seems very inconsistent to me. The DataProvider is used to get a product list and if it is a "child search" then it should consider the visibility of the product. But this paratmeter is only true when you try to query product links (related, upsell and crosssell). On top of it the if was changed 8ff8dbe which does not seem to actually to what is is intendet too. According to the implemented test is it supposed to take the status into account but in the code only the visibility is added. I think it only works implicitly (or by chance).

Examples (*)

When I query a product that is set to visibility 1 then I do receive it with the according visibility:

{
    products(filter: {sku: {eq: "SOME_SKU"}})
    {
        items {
            sku
            visibility
        }
    }
}

Result:
{
    "data": {
        "products": {
            "items": [
                {
                    "sku": "SOME_SKU",
                    "visibility": 1
                }
            ]
        }
    }
}

But when this product with visibility 1 is a related product to another product it will not be returned due to the visibility:

{
    products(filter: {sku: {eq: "SOME_OTHER_SKU"}})
    {
        items {
            sku
            visibility
            related_products
            {
                sku
                visibility
            }
        }
    }
}

Result:
{
    "data": {
        "products": {
            "items": [
                {
                    "sku": "SOME_OTHER_SKU",
                    "visibility": 4
                    "related_products": []
                }
            ]
        }
    }
}

Proposed solution

I think this is very inconsistent and we should either completely manage the visibility in the backend or frontend but not both.
My recommendation would be to handle it in the frontend and remove the following lines: https://github.com/magento/magento2/blob/2.4.3-p1/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php#L92-L97


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions