can somebody suggest me a way or a script to export a csv file with all product SKUs & the categories those SKUs are associated to?
I've tried several things... but nothing seems to work. Magento's product export isn't working for me.. It gives me errors.
I've tried the Aten's script [source code] but it prints the categories in json format..
so i've also tried this:
define('MAGENTO', realpath(dirname(__FILE__))); require_once MAGENTO . '/app/Mage.php'; Mage::app(); $category = Mage::getModel('catalog/category')->load($categoryId); $ids = $category->getCollection()->getAllIds(); if ($ids) { $file = "var/import/catwithid.csv"; file_put_contents($file,"category_ids, sku" . "\n"); foreach ( $ids as $id ) { $string = $id . ', ' . $category->load($id) . "\n"; file_put_contents($file, $string, FILE_APPEND); } }
and this
define('MAGENTOROOT', realpath(dirname(__FILE__)));
require_once(MAGENTOROOT.'/app/Mage.php');
umask(0);
Mage::app('default');
$products = Mage::getModel("catalog/product")->getCollection();
$products->addAttributeToFilter('status', 1);
$products->addAttributeToFilter('visibility', 4);
$products->load();
$fp = fopen('exports.csv', 'w');
$csvHeader = array("sku", "category_ids");
fputcsv( $fp, $csvHeader, $delimiter = ", ");
foreach( $products as $_product ) {
$sku = $_product->getData('sku');
$product = $_product->load($sku);
$product_row = array($sku);
fputcsv( $fp, $product_row, $delimiter = ", ");
}
I've also tried to merge them together but with no luck! :/
please help me!!