function import($merchant_id){
if(!empty($this->data['Product']['excel']['tmp_name'])){
$row = 1;
if (($handle = fopen($this->data['Product']['excel']['tmp_name'], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, "^")) !== FALSE && $row<30) {
//process and save data
$product['Product']['name']=$data[0];
$product['Product']['description']=$data[2];
$product['Product']['merchant_id']=$merchant_id;
$product['Product']['price']=$data[3];
$product['Product']['weight']=$data[4];
$product['Product']['status']=1;
$this->Product->create();
$this->Product->save($product,false);
}
$row++;
}
fclose($handle);
}
}
Tuesday, December 6, 2011
import csv
controller
Labels:
CAKEPHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment