I'm writing some info to a .csv file in Magento:

public function batch_update_attributeAction(){
    $attribute_id = $_GET['attribute_id'];
    $table_name = $_GET['table_name'];
    $input = $_GET['input'];
    $input = explode(';', $input);
    $connection = Mage::getModel('core/resource')-&gt;getConnection('core_read');
    #$connection_write = Mage::getModel('core/resource')-&gt;getConnection('core_write');
    $csv_array = array();
    array_push($csv_array, array('entity_id', 'name', 'previous_value', 'updated_value'));
    foreach ($input as $part){
        $parts = explode(",", $part);
        $entity_id = $parts[0];
        $value = $parts[1];
        $sql = 'SELECT `value` FROM ' . $table_name . ' WHERE `entity_id` = ? AND `attribute_id` = ?';
        $current_value = $connection-&gt;fetchOne($sql, array($entity_id, $attribute_id));
        $sql = 'SELECT `value` FROM `catalog_product_entity_varchar` WHERE `entity_id` = ? AND `attribute_id` = ?';
        $name = $connection-&gt;fetchOne($sql, array($entity_id, 56));
        array_push($csv_array, array($entity_id, $name, $current_value, $value));
        #echo "UPDATE `$table_name` SET `value` = $value WHERE `entity_id` = $entity_id AND `attribute_id` = $attribute_id&lt;br/&gt;";
    }
    $user = Mage::getSingleton('admin/session')-&gt;getUser()-&gt;getFirstname();
    $date = Mage::getModel('core/date')-&gt;timestamp(time());
    $date = date('Y-m-d', $date);
    header('Content-Type: application/csv');
    header('Content-Disposition: attachement; filename="$date $table_name update $user.csv";');
    $f = fopen('php://output', 'w');
    foreach ($csv_array as $line) {
        fputcsv($f, $line, ",");
    }
}


Other than the empty starting row, everything is perfect.

Interestingly enough, if I run this outside of the Magento code pool, i.e from a root script, it functions perfectly. Any input would be appreciated.


Question: Parse order and/or single/double quote issue with Calendar events and Google Map Info Window
Answer: I am not sure of a workaround, but that is definitely a parse order issue. Given this is a very unique scenario, it would be rather difficult to duplicate without getting access to your EE install.

Email support@objectivehtml.com and I can try to help you find a workaround. I am not sure who this support requests belongs to, me (Objective HTML), P&amp;T, or Solspace but I can try to help you. :)