How to Export Magento Categories


Magneto Data flow method will not export the categories. It used to export only the products. In this case you can run the below script inside your magento directory.

After run this script you can get the exported csv file insider the var/export directory with the file name cat_export.csv. in some cases if you don’t have permission for your var directory it will not allow to create the folder export. So you can manually create the export folder inside var directory.


define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';

$category = Mage::getModel ( 'catalog/category' );
$tree = $category->getTreeModel ();
$tree->load ();

$ids = $tree->getCollection ()->getAllIds ();

if ($ids) {
$file = "var/export/cat-export.csv";
file_put_contents($file,"Category ID, Category Name");
foreach ( $ids as $id ) {
$string = $id . ', ' .$category->load($id)->getName() . "\n";

Leave a Comment

Your email address will not be published. Required fields are marked *

× 7 = 7