From frontend i want to export csv.

I am using this code to export csv

    $attributeCodeToSkip = array(

    $skipAttrs = array();
    if ($attributeCodeToSkip) {
        foreach ($attributeCodeToSkip as $attributecode) {
            $attributeDetails = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributecode);
            $skipAttrs[]      = $attributeDetails->getAttributeId();
    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $data = array(
        "entity" => 'catalog_product',
        "file_format" => 'csv',
        "export_filter" => array(
            "vendor_customer_id" => $customer->getId()
        "skip_attr" => $skipAttrs

    $model = Mage::getModel('importexport/export');

    return $this->_prepareDownloadResponse($model->getFileName(), $model->export(), $model->getContentType());
    $store = Mage::app()->getStore();

using this I am getting all information about product except two field which i set in skip_attr but i want only product name,SKU and qty. in csv.

closed as unclear what you're asking by Amit Bera, Marius May 6 '15 at 6:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Write this code in your controller to get only Product name,sku,quantity

$products_model = Mage::getModel('catalog/product'); //get products model
    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $collection = Mage::getModel("catalog/product")->getCollection();

    $csv = '';
    $_columns = array(
        "Product Name",
    $datas = array();
    foreach ($_columns as $column) {
        $datas[] = '"'.$column.'"';
    $csv .= implode(',', $datas)."\n";
    $id = array(); 
    foreach ($collection as $collections)
        $id[] = $collections->getId();
    foreach ($id as $pid)
        $prod = $products_model->load($pid);
        $stock_item = Mage::getModel('cataloginventory/stock_item')->loadByProduct($pid);

        $data['sku'] = $prod->getSku();
        $productName = str_ireplace(',', '|', $prod->getName());
        $data['name'] = $productName;
        $data['qty'] = $stock_item->getQty();
        $csv .= implode(',', $data)."\n";   

    return $this->_prepareDownloadResponse('sample.csv', $csv);

Not the answer you're looking for? Browse other questions tagged or ask your own question.