Answer the question
In order to leave comments, you need to log in
How to set up excel import to import products with pictures?
I screwed up the excel import/export extension, tweaked it a little and it worked, but all the products are without pictures, and this is not a gut when there are a lot of products. And it's not comme il faut at all ...
The extension was installed by uranum/yii2-excel-exchange
Action:
public function actionImportExcel()
{
$inputFile = 'uploads/export.xlsx';
try{
$inputFileType = \PHPExcel_IOFactory::identify($inputFile);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFile);
} catch (\DomainException $e) {
die('Error');
}
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
for($row=1; $row <= $highestRow; $row++)
{
$rowData = $sheet->rangeToArray('A'.$row.':'.$highestColumn.$row,NULL,TRUE,FALSE);
if($row==1)
{
continue;
}
$product = new Product();
$product->brand_id = $rowData[0][0];
$product->category_id = $rowData[0][1];
$product->code = $rowData[0][2];
$product->name = $rowData[0][3];
$product->description = $rowData[0][4];
$product->price_new = $rowData[0][5];
$product->price_min = $rowData[0][6];
$product->price_roll = $rowData[0][7];
$product->meta = new Meta($rowData[0][8],
$rowData[0][9],
$rowData[0][10]
);
$product->status = $rowData[0][11];
$product->quantity = $rowData[0][12];
$product->min_long = $rowData[0][13];
$product->roll_long = $rowData[0][14];
$product->created_at = time();
$product->save();
print_r($product->getErrors());
}
return $this->render('index');
}
Answer the question
In order to leave comments, you need to log in
Well, how are the comrades doing?
I also struggle with pictures, though not through this module.
this module is not all the more
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question