Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Incorrect returned values of product_count #214

Closed
Serunde opened this issue Oct 15, 2018 · 7 comments
Closed

Incorrect returned values of product_count #214

Serunde opened this issue Oct 15, 2018 · 7 comments
Assignees
Labels

Comments

@Serunde
Copy link

Serunde commented Oct 15, 2018

Preconditions

  1. Using Magento 2.3
  2. Luma sample data installed

Steps to reproduce

  1. Form a category query including the product_count field with a category id of 3 (gear)
  2. Include an inner product query with the total_count field.

Expected result

product_count matches the total number of items returned from the query. Should be the same number as total_count if the inner product query does not have filters.

Actual result

productcount

Additional Notes

Worth mentioning that the value of product_count here is the same as the highest id in the category, despite the gap of products between id 23 and 36.

@ronak2ram
Copy link
Member

@Serunde
I debug this issue and I found.

There is product_count show product's count which has a Visibility is Catalog, Search or Not Visible Individually
There is total_count show product's count which has a Visibility is Catalog, Search

And, Result items has products which has a Visibility is Catalog, Search

Maybe this help to mentor.

@Serunde
Copy link
Author

Serunde commented Oct 24, 2018

@ronak2ram
Thanks for looking into this! So then this is the intended behavior of product_count?

@misha-kotov
Copy link

@ronak2ram @Serunde
Both fields should reflect products that have visibility set to Catalog, Search OR Catalog. Same should be reflected in the result set.
This is because querying products in this way emulates user browsing products (as opposed to using search) and therefore products that would be reflected on storefront in this case should be returned by GraphQL.

@ronak2ram
Copy link
Member

ronak2ram commented Oct 25, 2018

@Serunde Yes
@misha-kotov
We want product_count and total_count both should be same which has a Visibility is Catalog, Search only right?

@vpodorozh vpodorozh assigned vpodorozh and unassigned vpodorozh Nov 2, 2018
@misha-kotov
Copy link

@ronak2ram no, see my answer above. Products that are set to visibility Catalog should also be included.

@naydav
Copy link
Contributor

naydav commented May 3, 2019

@TomashKhamlai
Please, verify issue

@naydav naydav added this to the Release: 2.3.2 milestone May 3, 2019
@naydav naydav added bug Something isn't working Component: CatalogGraphQl labels May 3, 2019
@TomashKhamlai TomashKhamlai added the QA in progress We are checking label May 6, 2019
@naydav naydav modified the milestones: Release: 2.3.2, Release: 2.3.3 May 6, 2019
@TomashKhamlai
Copy link
Contributor

Query:

query category(
  $id: Int!
  $currentPage: Int!
  $pageSize: Int!
) {
  category(
    id: $id
  ) {
    name
    product_count
    products(
      currentPage: $currentPage
      pageSize: $pageSize
    ) {
      items {
        id
      }
      total_count
    }
  }
}

Variables:

{
  "id": 3,
  "currentPage": 6,
  "pageSize": 6
}

Response:

{
  "data": {
    "category": {
      "name": "Gear",
      "product_count": 34,
      "products": {
        "items": [
          {
            "id": 43
          },
          {
            "id": 44
          },
          {
            "id": 45
          },
          {
            "id": 52
          }
        ],
        "total_count": 34
      }
    }
  }
}

@TomashKhamlai TomashKhamlai added QA passed and removed QA in progress We are checking labels May 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants