tulparstudyo / sw-xlsx
Aimeos sw-xlsx 扩展 Swordbros
v1.0.1
2021-03-02 23:49 UTC
Requires
- php: ~7.1
- composer/installers: ^1.0
This package is auto-updated.
Last update: 2024-09-29 05:56:23 UTC
README
Aimeos 的产品导入导出
控制台命令
php artisan aimeos:jobs "product/export/xlsx" "default"
php artisan aimeos:jobs "product/import/xlsx" "default"
在 Laravel 控制器中使用示例
// Export xlsx file
<?php
$Xlsx = new \Aimeos\Controller\Jobs\Product\Export\Xlsx\Standard($this->get('context'), $this->get('aimeos'));
$files = $Xlsx->run();
if($files){
$file_path = $files[0];
header('Content-Type: application/download');
header("Content-Disposition: attachment; filename=".$Xlsx->getXlsxFilename(1));
header("Pragma: no-cache");
header("Expires: 0");
readfile($file_path);
die();
}
?>
// Import xlsx file
$location = $config->get( 'client/product/import/xlsx/location' );
$file_name = 'product-import-1.xlsx';
$file_path = $location .'/'.$file_name;
if($files = (array) $this->getView()->request()->getUploadedFiles()){
foreach($files as $file ){
$file->moveTo($file_path);
}
$Xlsx = new \Aimeos\Controller\Jobs\Product\Import\Xlsx\Standard($context, $this->getAimeos());
$Xlsx->run();
}
$context->getSession()->set( 'info', [$context->getI18n()->dt( 'admin', 'Items imported successfully' )] );
return $this->redirect( 'product', 'search');