Skip to content

Instantly share code, notes, and snippets.

@LeeSaferite
Created May 11, 2012 18:53
Show Gist options
  • Save LeeSaferite/2661677 to your computer and use it in GitHub Desktop.
Save LeeSaferite/2661677 to your computer and use it in GitHub Desktop.
Patch to fix Magento config section sorting bug
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 9d3350c..4af5c71
--- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
@@ -80,13 +80,22 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge
$configFields = Mage::getSingleton('adminhtml/config');
$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,8 +104,13 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge
'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);
+ }
+ }
foreach ($sections as $section) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment