Created
August 3, 2016 10:20
-
-
Save ppassmannpriv/a68d5197247377a0a06ee670bd960676 to your computer and use it in GitHub Desktop.
Export all Magento Categories with Name, ID
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 | |
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