Reputation: 1397
this is my first question here :) I need to export all my products from my Magento Shop in order to upload them in my own software. I need to export all the products from Magento and save them in a csv file.
I need to get the main category and the sub-category name of the product selected, the stock item. How have I to get these information?
Thanks
/**
* Export all the products
*/
public function export_products(){
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('custom_products_id')
->addAttributeToSelect('price')
->addAttributeToSelect('special_price')
->addAttributeToSelect('url_path')
->addAttributeToSelect('status')
->addAttributeToSelect('name');
foreach ($collection as $product) {
//var_dump($product);
#print_r($product->getData());
$categories = $product->getCategoryCollection();
foreach($categories as $category){
print_r($category->getData());
print_r(get_class_methods($category));
die;
}
die;
}
}
Upvotes: 0
Views: 787
Reputation: 21
Use the export command from the Config Menu in Admin and you can export to a CSV file.
The current export is a little messy in that items that have multiple categories are followed by lines that only have the additional category named.
You should be able to do an advanced export. More complicated would be to export from MySQL. Difficult in that there may be several tables that create the full description of the products.
Upvotes: 2