本文整理汇总了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);
}