Created
October 15, 2013 16:03
-
-
Save peterjaap/6993942 to your computer and use it in GitHub Desktop.
Dump categories to tabbed CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
chdir(dirname(__FILE__)); | |
require_once '../app/Mage.php'; | |
@$app = Mage::app($argv[1]); | |
$catalogId = $app->getStore()->getRootCategoryId(); | |
$category = Mage::getModel ('catalog/category'); | |
catalogTraversal($category,$catalogId); | |
function catalogTraversal( $category, $catalogId=null){ | |
$curCatalog = $category->load($catalogId); | |
$childCats = $curCatalog->getChildrenCategories(); | |
if (count($childCats) > 0){ | |
foreach ($childCats as $childCat){ | |
for ($j=0; $j<$childCat->getLevel(); $j++){ | |
echo ','; | |
} | |
echo '"' . addslashes($childCat->getName()). '"->"'. $childCat->getId().'"'; | |
echo "\n"; | |
catalogTraversal($category, $childCat->getId()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment