-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Product Collection - addMediaGalleryData calls getSize when the collection maybe or will be loaded (Can use count to avoid an extra DB query) #39111
Comments
Hi @steven-hoffman-jomashop. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-November. Thank you for working on this issue.
|
Hello @steven-hoffman-jomashop, Thank you for the report and collaboration! I agree that if the collection is already loaded we should call count, but |
Hi @engcom-November,
Please see above.
In summary: Those other uses, where the category is not yet loaded, will return false for |
Hello @steven-hoffman-jomashop, I agree with this, since there is a if clause it won't effect other implementation, hence confirming the issue. Thank you. |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-13055 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
❌ You don't have permission to export this issue. |
@magento I am working on this |
… when the collection maybe or will be loaded (Can use count to avoid an extra DB query) - Fixed call count instead of getSize if collection is loaded.
… when the collection maybe or will be loaded (Can use count to avoid an extra DB query) - Fixed call count instead of getSize if collection is loaded.
… when the collection maybe or will be loaded (Can use count to avoid an extra DB query) - Fixed call count instead of getSize if collection is loaded.
Preconditions and environment
The call to getSize is clearly un-needed for the GQL code path for products.
if (!$this->getSize()) {
on a collection that is loaded already. At this point we can call count. (Or just check the empty on the getItems).It should be safe to add a
if($this->isLoaded())
prior to calling getSize, and if loaded, call count instead of getSize.(It should also be safe to just use the count/empty of getItems, (As getItems calls load), but calling isLoaded and using count should be safe and would mitigate this specific issue).
Steps to reproduce
Expected result
getSize is not called on a loaded product collection. (When the non-paginated count is not needed).
Actual result
getSize is called on a loaded paginated collection to check if it has data.
Additional information
No response
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: