本文整理匯總了PHP中Varien_File_Csv::fputcsv方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_File_Csv::fputcsv方法的具體用法?PHP Varien_File_Csv::fputcsv怎麽用?PHP Varien_File_Csv::fputcsv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_File_Csv
的用法示例。
在下文中一共展示了Varien_File_Csv::fputcsv方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: exportTableratesAction
/**
* Export the eParcel table rates as a CSV file.
*/
public function exportTableratesAction()
{
$rates = Mage::getResourceModel('australia/shipping_carrier_eparcel_collection');
$response = array(array('Country', 'Region/State', 'Postcodes', 'Weight from', 'Weight to', 'Parcel Cost', 'Cost Per Kg', 'Delivery Type', 'Charge Code Individual', 'Charge Code Business'));
foreach ($rates as $rate) {
$countryId = $rate->getData('dest_country_id');
$countryCode = Mage::getModel('directory/country')->load($countryId)->getIso3Code();
$regionId = $rate->getData('dest_region_id');
$regionCode = Mage::getModel('directory/region')->load($regionId)->getCode();
$response[] = array($countryCode, $regionCode, $rate->getData('dest_zip'), $rate->getData('condition_from_value'), $rate->getData('condition_to_value'), $rate->getData('price'), $rate->getData('price_per_kg'), $rate->getData('delivery_type'), $rate->getData('charge_code_individual'), $rate->getData('charge_code_business'));
}
$csv = new Varien_File_Csv();
$temp = tmpfile();
foreach ($response as $responseRow) {
$csv->fputcsv($temp, $responseRow);
}
rewind($temp);
$contents = stream_get_contents($temp);
$this->_prepareDownloadResponse('tablerates.csv', $contents);
fclose($temp);
}