-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Category product count does not include products assigned to the category itself #40295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4-develop
Are you sure you want to change the base?
Category product count does not include products assigned to the category itself #40295
Conversation
|
Hi @mimou78. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
1 similar comment
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
…lf-reference-40263
…lf-reference-40263
…lf-reference-40263
app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php
Outdated
Show resolved
Hide resolved
app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/CollectionTest.php
Outdated
Show resolved
Hide resolved
|
@magento run all tests |
app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/CollectionTest.php
Show resolved
Hide resolved
swnsma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your changes!
Could you have a look at my small note about unit tests?
…' of github.com:mimou78/magento2 into fix/category-product-count-missing-self-reference-40263
|
@magento run all tests |
Hi, That's perfectly fine for me — I agree with proceeding with the PR as it is. I’ll be happy to continue working on a potential fix for the visibility behavior, and I appreciate your support for reviewing the PR. Thanks again! |
…lf-reference-40263
|
@magento run all tests |
|
@magento run Adobe CLA Signed? |
|
Failed to run the builds. Please try to re-run them later. |
|
@magento run all tests |
|
@magento run Functional Tests B2B,Functional Tests CE,Functional Tests EE |
1 similar comment
|
@magento run Functional Tests B2B,Functional Tests CE,Functional Tests EE |
…lf-reference-40263
|
@magento run all tests |
…lf-reference-40263
|
@magento run all tests |
swnsma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken tests do not related to the changes in the Pull Requests.
…lf-reference-40263
…lf-reference-40263
…lf-reference-40263
|
@magento run all tests |
|
Hi @mohaelmrabet, Thanks for the collaboration & contribution! ✔️ QA PassedPreconditions:
Steps to reproduce
Before: ✖️
After: ✔️
Builds are failed. Hence, moving this PR to Extended Testing. Thanks. |



Summary
This pull request fixes an issue where the product count displayed in the Admin Category Grid
incorrectly shows 0 products for categories that do not have any descendants.
The current logic only counts products assigned to descendant categories and does not
include products directly assigned to the category itself.
Problem
When building the temporary table of category → descendant relationships, the SQL
logic only inserts rows for descendants, not for the category itself.
As a result:
Related Issue
Fixes #40263
What This Fix Does
This change ensures that each category always includes a self-reference entry in
the temporary category/descendant table.
As a result:
Technical Changes
(category_id = X, descendant_id = X)for everyprocessed category ID.
and the category itself.
Testing Instructions
Backward Compatibility
Risks
Low. This affects only the temporary table generation used for counting, not
the category model or product relations.