Created
September 27, 2015 07:25
-
-
Save devjosh12/381e352fc14708f1107b to your computer and use it in GitHub Desktop.
Show Root Categories Alphabetically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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