Quick script to export Magento categories with IDs

If you are after a quick method to get all the category ID’s for your categories for some Excel lookups (for new data imports), then this quick PHP script should help you out: <?php define(‘MAGENTO’, realpath(dirname(__FILE__))); require_once MAGENTO . ‘/app/Mage.php’; Mage::app(); $category = Mage::getModel ( ‘catalog/category’ ); $tree = $category->getTreeModel (); $tree->load (); $ids = $tree->getCollection ()->getAllIds (); if ($ids) { $file = "var/import/catwithid.csv"; file_put_contents($file,"catId, catNamen"); foreach ( $ids as $id ) { $string = $id . ‘, ‘ .$category->load($id)->getName() . "n"; file_put_contents($file,$string,FILE_APPEND); } } Simply save the above code in a PHP file in the base Magento directory of your store, and visit the URL in your web browser, simples!