Skip to content

Instantly share code, notes, and snippets.

@pierreandreroy
Created December 23, 2013 18:24
Show Gist options
  • Save pierreandreroy/8102136 to your computer and use it in GitHub Desktop.
Save pierreandreroy/8102136 to your computer and use it in GitHub Desktop.
Get all Magento categories.
<?php
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('id')
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addAttributeToSelect('url')
->addAttributeToSelect('is_active');
foreach ($categories as $category)
{
if ($category->getIsActive()) { // Only pull Active categories
$entity_id = $category->getId();
$name = $category->getName();
$url_key = $category->getUrlKey();
$url_path = $category->getUrl();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment