Skip to content

Commit 07e37e3

Browse files
committed
B2B-2464: Improve category children loading
- Flattener only is concerned with custom_attributes - This fix is to prevent getChildren from being needlessly called via buildOutputDataArray (note that children is reset to empty array after that call)
1 parent 093ddc6 commit 07e37e3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/code/Magento/CatalogGraphQl/Model/Category/Hydrator.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public function __construct(
5757
*/
5858
public function hydrateCategory(Category $category, $basicFieldsOnly = false) : array
5959
{
60-
if ($basicFieldsOnly) {
61-
$categoryData = $category->getData();
62-
} else {
63-
$categoryData = $this->dataObjectProcessor->buildOutputDataArray($category, CategoryInterface::class);
60+
if (!$basicFieldsOnly) {
61+
// initialize custom attributes (to be consequently included in subsequent getData call below)
62+
$category->getCustomAttributes();
6463
}
64+
65+
$categoryData = $category->getData();
66+
6567
$categoryData['id'] = $category->getId();
6668
$categoryData['uid'] = $this->uidEncoder->encode((string) $category->getId());
6769
$categoryData['children'] = [];

0 commit comments

Comments
 (0)