Skip to content

Commit c807242

Browse files
EliasKotlyaredannenberg
authored andcommitted
[bug-OpenMage#351] Position attribute of child categories is ignored
Categories returned by getChildren() should be sorted by position. refs: OpenMage#350
1 parent bbf1921 commit c807242

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/code/core/Mage/Catalog/Model/Resource/Category.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ public function getChildren($category, $recursive = true)
727727
'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = m.entity_id',
728728
array()
729729
)
730-
->where($checkSql . ' = :scope');
730+
->where($checkSql . ' = :scope')
731+
->order("m.position ASC");
731732

732733
return $adapter->fetchCol($select, $bind);
733734
}

app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,15 +1311,18 @@ public function isInRootCategoryList($category)
13111311
*/
13121312
public function getChildren($category, $recursive = true, $isActive = true)
13131313
{
1314+
$maintable = $this->getMainStoreTable($category->getStoreId());
13141315
$select = $this->_getReadAdapter()->select()
1315-
->from($this->getMainStoreTable($category->getStoreId()), 'entity_id')
1316-
->where('path LIKE ?', "{$category->getPath()}/%");
1316+
->from($maintable, 'entity_id')
1317+
->where('path LIKE ?', "{$category->getPath()}/%")
1318+
->order($maintable.".position ASC");
13171319
if (!$recursive) {
13181320
$select->where('level <= ?', $category->getLevel() + 1);
13191321
}
13201322
if ($isActive) {
13211323
$select->where('is_active = ?', '1');
13221324
}
1325+
13231326
$_categories = $this->_getReadAdapter()->fetchAll($select);
13241327
$categoriesIds = array();
13251328
foreach ($_categories as $_category) {

0 commit comments

Comments
 (0)