Skip to content

Commit 22e6839

Browse files
committed
B2B-2464: Improve category children loading
- Use fetchCol to avoid creation of collection models
1 parent d85ce24 commit 22e6839

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,16 @@ public function getResult(array $criteria, StoreInterface $store, array $attribu
101101
$categories->setSearchCriteria($searchCriteria);
102102

103103
// only fetch necessary category entity id
104-
$collection
105-
->getSelect()
104+
$select = $collection->getSelect();
105+
$select
106106
->reset(Select::COLUMNS)
107107
->columns(
108108
'e.entity_id'
109109
);
110-
$categories->setItems($collection->getItems());
111-
$categories->setTotalCount($collection->getSize());
110+
$categoryIds = array_map('intval', $collection->getConnection()->fetchCol($select));
112111

113-
$categoryIds = [];
114-
foreach ($categories->getItems() as $category) {
115-
$categoryIds[] = (int)$category->getId();
116-
}
112+
$categories->setItems($categoryIds);
113+
$categories->setTotalCount(count($categoryIds));
117114

118115
$totalPages = 0;
119116
if ($categories->getTotalCount() > 0 && $searchCriteria->getPageSize() > 0) {

0 commit comments

Comments
 (0)