Magento: Export product attributes with category name and product URL

You can use following code to export product attributes, categories, and complete product URL link. Customize it according to your need.

require_once 'app/Mage.php';
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
$userModel = Mage::getModel('admin/user');
$collection = Mage::getModel('catalog/product')
->addAttributeToSelect('*') //Select everything from the table
->addUrlRewrite(); //Generate nice URLs

fputcsv($output, array(
'sku', 'Category ', 'Color', 'url_key'

foreach($collection as $product) {
$_cat = array();
$categoryName = array();

foreach ($product->getCategoryIds() as $Id) {
$_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($Id);
$categoryName[] = $_cat->getName();
$color = array();
$color = implode(',', $product->getAttributeText('color'));
$comma_separated = implode(",", $categoryName);
fputcsv($output, array(