Skip to content

Commit f77dadb

Browse files
author
Denis Ristic
committed
ADDED $sortByPosition flag to Magento\Catalog\Model\Category
ADDED test testGetChildrenSroted() to integration testsuite Magento\Catalog\Model\Category
1 parent 6dfb610 commit f77dadb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,12 @@ public function getAllChildren($asArray = false)
780780
/**
781781
* Retrieve children ids comma separated
782782
*
783+
* @param boolean $sortByPosition
783784
* @return string
784785
*/
785-
public function getChildren()
786+
public function getChildren($sortByPosition = false)
786787
{
787-
return implode(',', $this->getResource()->getChildren($this, false));
788+
return implode(',', $this->getResource()->getChildren($this, false, true, $sortByPosition));
788789
}
789790

790791
/**

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public function testGetChildren()
128128
$this->assertEquals(array_diff([4, 13], explode(',', $this->_model->getChildren())), []);
129129
}
130130

131+
public function testGetChildrenSorted()
132+
{
133+
$this->_model->load(2);
134+
$this->assertEquals(array_diff([3, 4, 5], explode(',', $this->_model->getChildren(true))), []);
135+
}
136+
131137
public function testGetPathInStore()
132138
{
133139
$this->_model->load(5);

0 commit comments

Comments
 (0)