From 2c3bffa5e0964171a821a47a02cdd4c4297bd8ac Mon Sep 17 00:00:00 2001 From: Lee Saferite Date: Mon, 14 May 2012 12:32:18 -0400 Subject: [PATCH] Fixed admin config section ordering bug The config section sort_order was updated to respect the containing tab's sort order in addition to the section sort order. Now sections are sorted in the context of the tab and the final list of sections is built first on the tab sort_order, then the section sort_order. This fixes a problem with sections that do not have a sort_order becoming the default section. The default section is now the first section of the first tab. --- .../Adminhtml/Block/System/Config/Tabs.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php index 874406866..7ce95b1c4 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php @@ -81,12 +81,20 @@ public function initTabs() $sections = $configFields->getSections($current); $tabs = (array)$configFields->getTabs()->children(); - - $sections = (array)$sections; - - usort($sections, array($this, '_sort')); usort($tabs, array($this, '_sort')); + $tabSections = array(); + foreach ((array)$sections as $section) { + $tab = (string)$section->tab; + if (!empty($tab)) { + if (!isset($tabSections[$tab])) { + $tabSections[$tab] = array(); + } + $tabSections[$tab][] = $section; + } + } + $sections = array(); + foreach ($tabs as $tab) { $helperName = $configFields->getAttributeModule($tab); $label = Mage::helper($helperName)->__((string)$tab->label); @@ -95,6 +103,12 @@ public function initTabs() 'label' => $label, 'class' => (string) $tab->class )); + + if (isset($tabSections[$tab->getName()])) { + $section = $tabSections[$tab->getName()]; + usort($section, array($this, '_sort')); + $sections = array_merge($sections, $section); + } }