B-219 Sec-55 Noida, India
+918010221733

Script to export magento categories

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);
}
}
?>
(Visited 131 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.