Skip to content

Instantly share code, notes, and snippets.

@mukundthanki
Last active December 14, 2015 04:29
Show Gist options
  • Save mukundthanki/5028117 to your computer and use it in GitHub Desktop.
Save mukundthanki/5028117 to your computer and use it in GitHub Desktop.
Magento: Load selected categories in magento
<?php
$categories = Mage::getModel('catalog/category')->getCollection();
$categories->addAttributeToSelect('*');
$categories->addAttributeToFilter('is_active', 1);
$categories->addAttributeToFilter('entity_id', array('in' => array(3,4,5,6,7)));// Loading selected categories by passing array
$categories->load();
// Normal list of categories
if($categories){
echo "<ul>";
foreach($categories as $category){
echo "<li><a href='".$category->getUrl()."'>".$category->getName()."</a></li>";
}
echo "</ul>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment