Skip to content

Instantly share code, notes, and snippets.

@ppassmannpriv
Created August 3, 2016 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppassmannpriv/a68d5197247377a0a06ee670bd960676 to your computer and use it in GitHub Desktop.
Save ppassmannpriv/a68d5197247377a0a06ee670bd960676 to your computer and use it in GitHub Desktop.
Export all Magento Categories with Name, ID
<?php
require_once 'app/Mage.php';
Mage::app();
$_categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*');
$_file = __DIR__."/categories.csv";
$_export = fopen($_file, 'w') or die('Permission denied - check filesettings');
$_output = "";
$_output = "\"Name\", \"ID\"\r\n";
fwrite($_export, $_output);
foreach($_categories as $_category)
{
$_output = "";
$_output .= '"'.$_category->getName().'", ';
$_output .= $_category->getId();
$_output .= "\r\n";
fwrite($_export, $_output);
}
fclose($_export);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment