Skip to main content
added 614 characters in body
Source Link
Jaimin
  • 2.2k
  • 1
  • 29
  • 56

For Understand first try this

 <?php   echo "<pre/>";  $categories = Mage::getResourceModel('catalog/category_collection')   ->addAttributeToSort('name','ASC')   ->getData('name');    for ($i=0; $i < count($categories); $i++)  {   echo $categories[$i]['name']."<br/>";  }    die(); ?> 

For Output :-

<?php $_categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('is_active') ->addAttributeToSort('name','ASC') ->addUrlRewriteToResult(); foreach($_categories as $_category) { echo "<a href=".$_category->getUrl($_category).">".$_category->getName($_category)."</a><br/>"; //echo "<pre/>"; //echo $_category->getUrl($_category); } die; ?> 
<?php echo "<pre/>"; $categories = Mage::getResourceModel('catalog/category_collection') ->addAttributeToSort('name','ASC') ->getData('name'); for ($i=0; $i < count($categories); $i++) { echo $categories[$i]['name']."<br/>"; } die(); ?> 

For Understand first try this

 <?php   echo "<pre/>";  $categories = Mage::getResourceModel('catalog/category_collection')   ->addAttributeToSort('name','ASC')   ->getData();    for ($i=0; $i < count($categories); $i++)  {   echo $categories[$i]['name']."<br/>";  }    die(); ?> 

For Output :-

<?php $_categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('is_active') ->addAttributeToSort('name','ASC') ->addUrlRewriteToResult(); foreach($_categories as $_category) { echo "<a href=".$_category->getUrl($_category).">".$_category->getName($_category)."</a><br/>"; //echo "<pre/>"; //echo $_category->getUrl($_category); } die; ?> 
Source Link
Jaimin
  • 2.2k
  • 1
  • 29
  • 56

<?php echo "<pre/>"; $categories = Mage::getResourceModel('catalog/category_collection') ->addAttributeToSort('name','ASC') ->getData('name'); for ($i=0; $i < count($categories); $i++) { echo $categories[$i]['name']."<br/>"; } die(); ?>