-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
No children data for \Magento\Catalog\Model\CategoryManagement::getTree($categoryId) after first call. #17297
Comments
Hi @j0um. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @j0um do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@magento-engcom-team give me {2.2.5} instance |
Hi @j0um, thank you for your report. |
Hi @pmclain. Thank you for working on this issue.
|
…tTree Tree::getNode currently loads nodes using a resource singleton. The tree resource's parent class contains the property _loaded and only loads child nodes when _loaded is false. This behavior means only the first call to CategoryManagement::getTree in a request returns child nodes. Fixes magento#17297
Hello @pmclain , this issue still reproduced for me, if I need to get several trees of different Root Categories.
Only first tree has children It caused shared $categoryCollection property in Magento/Catalog/Model/Category/Tree.php
But, would be better to fix this using by using factory for collection in __construct in Magento core code What do you think? |
The Magento implementation of the CategoryManagementInterface::getTree($rootCategoryId) does not provide a tree with children data after the first function usage.
Preconditions
Steps to reproduce
In a console script making use of \Magento\Catalog\Model\CategoryManagement, do the following :
$categoryId = 1; // Any valid category id.
$hasChildren = $categoryManagement->getTree($categoryId)->getChildrenData();
$noChildren = $categoryManagement->getTree($categoryId)->getChildrenData();
if (count($hasChildren) != count($noChildren)) {
// Well this is unexpected.
}
Expected result
I expect $noChildren to be populated with children.
Actual result
$noChildren's children_data is an empty array.
The text was updated successfully, but these errors were encountered: