Skip to content

Instantly share code, notes, and snippets.

@devjosh12
Created September 27, 2015 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devjosh12/381e352fc14708f1107b to your computer and use it in GitHub Desktop.
Save devjosh12/381e352fc14708f1107b to your computer and use it in GitHub Desktop.
Show Root Categories Alphabetically
<?php
$cats = Mage::getModel('catalog/category')->load(3)->getChildren();
$catIds = explode(',',$cats);
$categories = array();
foreach($catIds as $catId) {
$category = Mage::getModel('catalog/category')->load($catId);
$categories[$category->getName()] = $category->getId();
}
ksort($categories, SORT_STRING);
?>
<select class="input-text " id="partner_cats" name="partner_cats[]" title="partner_cats" style="height:20%;" multiple>
<?php foreach($categories as $name): ?>
<?php $cat = Mage::getModel('catalog/category');
$cat->load($name); ?>
<option value="<?php echo $name; ?>"><?php echo $cat->getName(); ?></option>
<?php endforeach; ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment