Skip to content

Commit

Permalink
ADDED $sortByPostion flag to getChildren()
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Ristic committed Oct 10, 2017
1 parent d30f077 commit 6dfb610
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,10 @@ public function isInRootCategoryList($category)
* @param \Magento\Catalog\Model\Category $category
* @param bool $recursive
* @param bool $isActive
* @param bool $sortByPosition
* @return array
*/
public function getChildren($category, $recursive = true, $isActive = true)
public function getChildren($category, $recursive = true, $isActive = true, $sortByPosition = false)
{
$select = $this->getConnection()->select()->from(
$this->getMainStoreTable($category->getStoreId()),
Expand All @@ -619,6 +620,9 @@ public function getChildren($category, $recursive = true, $isActive = true)
if ($isActive) {
$select->where('is_active = ?', '1');
}
if ($sortByPosition) {
$select->order('position ASC');
}
$_categories = $this->getConnection()->fetchAll($select);
$categoriesIds = [];
foreach ($_categories as $_category) {
Expand Down

0 comments on commit 6dfb610

Please sign in to comment.