Magento: Export Category List as CSV Format

Using the below code, you can export magneto category list as CSV format. Place the code in your root directory, and the exported file will be saved on  var/export directory.  So the CSV format includes

"Root Category Id", "Category Id", "Category Name", "Category URL", "Category Image", "Category Page Title", "Category Meta Keywords", "Category Mate Description","Category Is Active"
require_once 'app/Mage.php';
Mage::app();
$mageCategory = Mage::getModel ( 'catalog/category');
$categoryTree = $mageCategory->getTreeModel();
$categoryTree->load();
$categoryListIds = $categoryTree->getCollection()->getAllIds();
if ($categoryListIds) {
    $outputFileDir = "var/export/categories-detail.csv";
    $writeFile = fopen($outputFileDir, 'w');
    foreach ($categoryListIds as $categoryListId) {
        $categoryModel = $mageCategory->load($categoryListId);
        $parentCategoryId = $categoryModel->getParentId();
        $categoryId = $categoryModel->getId();
        $categoryName = $categoryModel->getName();
        $categoryUrl = $categoryModel->getUrl();
        $categoryImage = $categoryModel->getImage();
        $categoryPageTitle = $categoryModel->getMetaTitle();
        $categoryPageKeywords = $categoryModel->getMetaKeywords();
        $categoryPageDescription = $categoryModel->getMetaDescription();
        $categoryActive = $categoryModel->getIsActive();
        $collection = $mageCategory->getProductCollection();
        $data = array($parentCategoryId, $categoryId, $categoryName, $categoryUrl, $categoryImage, $categoryPageTitle, $categoryPageKeywords, $categoryPageDescription, $categoryActive);
        fputcsv($writeFile, $data);
        $i++;
    }
}
fclose($write);
Advertisements

Shopping Mall Landing Page Template

minewebdesign landing page
Responsive Shopping Mall Template,  It’s a clean & fluid shopping mall landing page template.
Features:
  • Minimal Code
  • Responsive Template
  • Clean & Fluid
  • HTML5 & CSS3
  • Supports major browsers.

Demo the template using following link.

Demo