Magento: Export Category List as CSV Format

Post Recently Updated, Use following URL:

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';
$mageCategory = Mage::getModel ( 'catalog/category');
$categoryTree = $mageCategory->getTreeModel();
$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);

Post Recently Updated, Use following URL:


Exact Difference Between Echo and Print in PHP

PHP Echo() and Print()


boolean print (argument)

print() is capable of displaying both strings and variables.
print() returns a Boolean Type, expresses a true value.

$language = "PHP";
$authour = "Rasmus Lerdorf";
$starts = 1994;

print $language;  // Resulting "PHP";

print $language.''.$authour;  
// Resulting "PHPRasmus Lerdorf"
// Multiple strings display using Concatenation(.) Operator. 
// print() has restricted of use comma(,) separator to display
multiple string, only echo() will do.

$year = print $starts;  // Resulting "1994" 

print $year; // Resulting Boolean Type "1"


void echo (string argument1 [, ...string argumentN])

echo() is capable of displaying multiple strings and variables.
echo() doesn’t returns a Boolean Type, because it returns void.

$language = "PHP";
$authour = "Rasmus Lerdorf";
$starts = 1994;
echo $language; // Resulting "PHP"

echo $language,$authour; 
// Resulting "PHPRasmus Lerdorf"
// Displaying multiple string using comma(,) separator.

$year = echo $starts;  
// Syntax Error, Because print() has capable to result the output.

*echo() function is a faster, because it returns nothing, whereas print() returns a Boolean value.