getCollection() ->addAttribut"/>
Engine23

Magento - Create a CSV of all categories

In case you need to export to a csv all the categories in your site, here is the code.

The csv just has the ID of the category, the Name of the category and the url key


$categories = Mage::getModel("catalog/category")->getCollection()
 ->addAttributeToSelect('name')
 ->addAttributeToSelect('url_key');

fputcsv($file,array('Category ID', 'Name', 'URL Key'));

// id, name, url-key
foreach($categories as $_category)
{
 fputcsv($file,array($_category->getData('entity_id'), $_category->getData('name'), $_category->getData('url_key')));

}
fclose($file);

Share: