<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\Controller\Admin\Product;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Eccube\Common\Constant;
use Eccube\Controller\Admin\AbstractCsvImportController;
use Eccube\Entity\BaseInfo;
use Eccube\Entity\Category;
use Eccube\Entity\Product;
use Eccube\Entity\ProductCategory;
use Eccube\Entity\ProductClass;
use Eccube\Entity\ProductImage;
use Eccube\Entity\ProductStock;
use Eccube\Entity\ProductTag;
use Eccube\Form\Type\Admin\CsvImportType;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\CategoryRepository;
use Eccube\Repository\ClassCategoryRepository;
use Eccube\Repository\DeliveryDurationRepository;
use Eccube\Repository\Master\ProductStatusRepository;
use Eccube\Repository\Master\SaleTypeRepository;
use Eccube\Repository\ProductImageRepository;
use Eccube\Repository\ProductRepository;
use Eccube\Repository\TagRepository;
use Eccube\Repository\TaxRuleRepository;
use Eccube\Service\CsvImportService;
use Eccube\Stream\Filter\ConvertLineFeedFilter;
use Eccube\Stream\Filter\SjisToUtf8EncodingFilter;
use Eccube\Util\CacheUtil;
use Eccube\Util\StringUtil;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Eccube\Controller\Admin\Product\CsvImportController;
class CsvImportControllerCustomizer extends CsvImportController
{
/**
* 商品登録CSVアップロード
*
* @Route("/%eccube_admin_route%/product/product_csv_upload", name="admin_product_csv_import", methods={"GET", "POST"})
* @Template("@admin/Product/csv_product.twig")
*
* @return array
*
* @throws \Doctrine\DBAL\ConnectionException
* @throws \Doctrine\ORM\NoResultException
*/
public function csvProduct(Request $request, CacheUtil $cacheUtil)
{
$form = $this->formFactory->createBuilder(CsvImportType::class)->getForm();
$headers = $this->getProductCsvHeader();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$this->isSplitCsv = $form['is_split_csv']->getData();
$this->csvFileNo = $form['csv_file_no']->getData();
$formFile = $form['import_file']->getData();
if (!empty($formFile)) {
log_info('商品CSV登録開始');
$data = $this->getImportData($formFile);
if ($data === false) {
$this->addErrors(trans('admin.common.csv_invalid_format'));
return $this->renderWithError($form, $headers, false);
}
$getId = function ($item) {
return $item['id'];
};
$requireHeader = array_keys(array_map($getId, array_filter($headers, function ($value) {
return $value['required'];
})));
$columnHeaders = $data->getColumnHeaders();
if (count(array_diff($requireHeader, $columnHeaders)) > 0) {
$this->addErrors(trans('admin.common.csv_invalid_format'));
return $this->renderWithError($form, $headers, false);
}
$size = count($data);
if ($size < 1) {
$this->addErrors(trans('admin.common.csv_invalid_no_data'));
return $this->renderWithError($form, $headers, false);
}
$headerSize = count($columnHeaders);
$headerByKey = array_flip(array_map($getId, $headers));
$deleteImages = [];
$this->entityManager->getConfiguration()->setSQLLogger(null);
$this->entityManager->getConnection()->beginTransaction();
// CSVファイルの登録処理
foreach ($data as $row) {
$line = $this->convertLineNo($data->key() + 1);
$this->currentLineNo = $line;
if ($headerSize != count($row)) {
$message = trans('admin.common.csv_invalid_format_line', ['%line%' => $line]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
}
if (!isset($row[$headerByKey['id']]) || StringUtil::isBlank($row[$headerByKey['id']])) {
$Product = new Product();
$this->entityManager->persist($Product);
} else {
if (preg_match('/^\d+$/', $row[$headerByKey['id']])) {
$Product = $this->productRepository->find($row[$headerByKey['id']]);
if (!$Product) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['id']]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['id']]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
}
if (isset($row[$headerByKey['product_del_flg']])) {
if (StringUtil::isNotBlank($row[$headerByKey['product_del_flg']]) && $row[$headerByKey['product_del_flg']] == (string) Constant::ENABLED) {
// 商品を物理削除
$deleteImages[] = $Product->getProductImage();
try {
$this->productRepository->delete($Product);
$this->entityManager->flush();
continue;
} catch (ForeignKeyConstraintViolationException $e) {
$message = trans('admin.common.csv_invalid_foreign_key', ['%line%' => $line, '%name%' => $Product->getName()]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
}
}
}
}
if (StringUtil::isBlank($row[$headerByKey['status']])) {
$message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['status']]);
$this->addErrors($message);
} else {
if (preg_match('/^\d+$/', $row[$headerByKey['status']])) {
$ProductStatus = $this->productStatusRepository->find($row[$headerByKey['status']]);
if (!$ProductStatus) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['status']]);
$this->addErrors($message);
} else {
$Product->setStatus($ProductStatus);
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['status']]);
$this->addErrors($message);
}
}
if (StringUtil::isBlank($row[$headerByKey['name']])) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['name']]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
} else {
$Product->setName(StringUtil::trimAll($row[$headerByKey['name']]));
}
if (isset($row[$headerByKey['note']])) {
if (StringUtil::isNotBlank($row[$headerByKey['note']])) {
$Product->setNote(StringUtil::trimAll($row[$headerByKey['note']]));
} else {
$Product->setNote(null);
}
}
if (isset($row[$headerByKey['description_list']])) {
if (StringUtil::isNotBlank($row[$headerByKey['description_list']])) {
$Product->setDescriptionList(StringUtil::trimAll($row[$headerByKey['description_list']]));
} else {
$Product->setDescriptionList(null);
}
}
if (isset($row[$headerByKey['description_detail']])) {
if (StringUtil::isNotBlank($row[$headerByKey['description_detail']])) {
if (mb_strlen($row[$headerByKey['description_detail']]) > $this->eccubeConfig['eccube_ltext_len']) {
$message = trans('admin.common.csv_invalid_description_detail_upper_limit', [
'%line%' => $line,
'%name%' => $headerByKey['description_detail'],
'%max%' => $this->eccubeConfig['eccube_ltext_len'],
]);
$this->addErrors($message);
return $this->renderWithError($form, $headers);
} else {
$Product->setDescriptionDetail(StringUtil::trimAll($row[$headerByKey['description_detail']]));
}
} else {
$Product->setDescriptionDetail(null);
}
}
// ▼追加項目ここから
if (isset($row[$headerByKey['brand']])) {
if (StringUtil::isNotBlank($row[$headerByKey['brand']])) {
$Product->setBrand(StringUtil::trimAll($row[$headerByKey['brand']]));
} else {
$Product->setBrand(null);
}
}
if (isset($row[$headerByKey['number']])) {
if (StringUtil::isNotBlank($row[$headerByKey['number']])) {
$Product->setNumber(StringUtil::trimAll($row[$headerByKey['number']]));
} else {
$Product->setNumber(null);
}
}
if (isset($row[$headerByKey['size']])) {
if (StringUtil::isNotBlank($row[$headerByKey['size']])) {
$Product->setSize(StringUtil::trimAll($row[$headerByKey['size']]));
} else {
$Product->setSize(null);
}
}
if (isset($row[$headerByKey['material']])) {
if (StringUtil::isNotBlank($row[$headerByKey['material']])) {
$Product->setMaterial(StringUtil::trimAll($row[$headerByKey['material']]));
} else {
$Product->setMaterial(null);
}
}
if (isset($row[$headerByKey['notification_email']])) {
if (StringUtil::isNotBlank($row[$headerByKey['notification_email']])) {
$Product->setNotificationEmail(StringUtil::trimAll($row[$headerByKey['notification_email']]));
} else {
$Product->setNotificationEmail(null);
}
}
// ▲追加項目ここまで
if (isset($row[$headerByKey['search_word']])) {
if (StringUtil::isNotBlank($row[$headerByKey['search_word']])) {
$Product->setSearchWord(StringUtil::trimAll($row[$headerByKey['search_word']]));
} else {
$Product->setSearchWord(null);
}
}
if (isset($row[$headerByKey['free_area']])) {
if (StringUtil::isNotBlank($row[$headerByKey['free_area']])) {
$Product->setFreeArea(StringUtil::trimAll($row[$headerByKey['free_area']]));
} else {
$Product->setFreeArea(null);
}
}
// 商品画像登録
$this->createProductImage($row, $Product, $data, $headerByKey);
$this->entityManager->flush();
// 商品カテゴリ登録
$this->createProductCategory($row, $Product, $data, $headerByKey);
// タグ登録
$this->createProductTag($row, $Product, $data, $headerByKey);
// 商品規格が存在しなければ新規登録
/** @var ProductClass[] $ProductClasses */
$ProductClasses = $Product->getProductClasses();
if ($ProductClasses->count() < 1) {
// 規格分類1(ID)がセットされていると規格なし商品、規格あり商品を作成
$ProductClassOrg = $this->createProductClass($row, $Product, $data, $headerByKey);
if ($this->BaseInfo->isOptionProductDeliveryFee()) {
if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
$deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
$errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
$ProductClassOrg->setDeliveryFee($deliveryFee);
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
$this->addErrors($message);
}
}
}
// 商品別税率機能が有効の場合に税率を更新
if ($this->BaseInfo->isOptionProductTaxRule()) {
if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) {
$taxRate = $row[$headerByKey['tax_rate']];
$errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
if ($ProductClassOrg->getTaxRule()) {
// 商品別税率の設定があれば税率を更新
$ProductClassOrg->getTaxRule()->setTaxRate($taxRate);
} else {
// 商品別税率の設定がなければ新規作成
$TaxRule = $this->taxRuleRepository->newTaxRule();
$TaxRule->setTaxRate($taxRate);
$TaxRule->setApplyDate(new \DateTime());
$TaxRule->setProduct($Product);
$TaxRule->setProductClass($ProductClassOrg);
$ProductClassOrg->setTaxRule($TaxRule);
}
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]);
$this->addErrors($message);
}
} else {
// 税率の入力がなければ税率の設定を削除
if ($ProductClassOrg->getTaxRule()) {
$this->taxRuleRepository->delete($ProductClassOrg->getTaxRule());
$ProductClassOrg->setTaxRule(null);
}
}
}
if (isset($row[$headerByKey['class_category1']]) && StringUtil::isNotBlank($row[$headerByKey['class_category1']])) {
if (isset($row[$headerByKey['class_category2']]) && $row[$headerByKey['class_category1']] == $row[$headerByKey['class_category2']]) {
$message = trans('admin.common.csv_invalid_not_same', [
'%line%' => $line,
'%name1%' => $headerByKey['class_category1'],
'%name2%' => $headerByKey['class_category2'],
]);
$this->addErrors($message);
} else {
// 商品規格あり
// 規格分類あり商品を作成
$ProductClass = clone $ProductClassOrg;
$ProductStock = clone $ProductClassOrg->getProductStock();
// 規格分類1、規格分類2がnullであるデータを非表示
$ProductClassOrg->setVisible(false);
// 規格分類1、2をそれぞれセットし作成
$ClassCategory1 = null;
if (preg_match('/^\d+$/', $row[$headerByKey['class_category1']])) {
$ClassCategory1 = $this->classCategoryRepository->find($row[$headerByKey['class_category1']]);
if (!$ClassCategory1) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category1']]);
$this->addErrors($message);
} else {
$ProductClass->setClassCategory1($ClassCategory1);
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category1']]);
$this->addErrors($message);
}
if (isset($row[$headerByKey['class_category2']]) && StringUtil::isNotBlank($row[$headerByKey['class_category2']])) {
if (preg_match('/^\d+$/', $row[$headerByKey['class_category2']])) {
$ClassCategory2 = $this->classCategoryRepository->find($row[$headerByKey['class_category2']]);
if (!$ClassCategory2) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
} else {
if ($ClassCategory1 &&
($ClassCategory1->getClassName()->getId() == $ClassCategory2->getClassName()->getId())
) {
$message = trans('admin.common.csv_invalid_not_same', ['%line%' => $line, '%name1%' => $headerByKey['class_category1'], '%name2%' => $headerByKey['class_category2']]);
$this->addErrors($message);
} else {
$ProductClass->setClassCategory2($ClassCategory2);
}
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
}
}
$ProductClass->setProductStock($ProductStock);
$ProductStock->setProductClass($ProductClass);
$this->entityManager->persist($ProductClass);
$this->entityManager->persist($ProductStock);
}
} else {
if (isset($row[$headerByKey['class_category2']]) && StringUtil::isNotBlank($row[$headerByKey['class_category2']])) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
}
}
} else {
// 商品規格の更新
$flag = false;
$classCategoryId1 = StringUtil::isBlank($row[$headerByKey['class_category1']]) ? null : $row[$headerByKey['class_category1']];
$classCategoryId2 = StringUtil::isBlank($row[$headerByKey['class_category2']]) ? null : $row[$headerByKey['class_category2']];
foreach ($ProductClasses as $pc) {
$classCategory1 = is_null($pc->getClassCategory1()) ? null : $pc->getClassCategory1()->getId();
$classCategory2 = is_null($pc->getClassCategory2()) ? null : $pc->getClassCategory2()->getId();
// 登録されている商品規格を更新
if ($classCategory1 == $classCategoryId1 &&
$classCategory2 == $classCategoryId2
) {
$this->updateProductClass($row, $Product, $pc, $data, $headerByKey);
if ($this->BaseInfo->isOptionProductDeliveryFee()) {
if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
$deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
$errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
$pc->setDeliveryFee($deliveryFee);
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
$this->addErrors($message);
}
}
}
// 商品別税率機能が有効の場合に税率を更新
if ($this->BaseInfo->isOptionProductTaxRule()) {
if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) {
$taxRate = $row[$headerByKey['tax_rate']];
$errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
if ($pc->getTaxRule()) {
// 商品別税率の設定があれば税率を更新
$pc->getTaxRule()->setTaxRate($taxRate);
} else {
// 商品別税率の設定がなければ新規作成
$TaxRule = $this->taxRuleRepository->newTaxRule();
$TaxRule->setTaxRate($taxRate);
$TaxRule->setApplyDate(new \DateTime());
$TaxRule->setProduct($Product);
$TaxRule->setProductClass($pc);
$pc->setTaxRule($TaxRule);
}
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]);
$this->addErrors($message);
}
} else {
// 税率の入力がなければ税率の設定を削除
if ($pc->getTaxRule()) {
$this->taxRuleRepository->delete($pc->getTaxRule());
$pc->setTaxRule(null);
}
}
}
$flag = true;
break;
}
}
// 商品規格を登録
if (!$flag) {
$pc = $ProductClasses[0];
if ($pc->getClassCategory1() == null &&
$pc->getClassCategory2() == null
) {
// 規格分類1、規格分類2がnullであるデータを非表示
$pc->setVisible(false);
}
if (isset($row[$headerByKey['class_category1']]) && isset($row[$headerByKey['class_category2']])
&& $row[$headerByKey['class_category1']] == $row[$headerByKey['class_category2']]) {
$message = trans('admin.common.csv_invalid_not_same', [
'%line%' => $line,
'%name1%' => $headerByKey['class_category1'],
'%name2%' => $headerByKey['class_category2'],
]);
$this->addErrors($message);
} else {
// 必ず規格分類1がセットされている
// 規格分類1、2をそれぞれセットし作成
$ClassCategory1 = null;
if (preg_match('/^\d+$/', $classCategoryId1)) {
$ClassCategory1 = $this->classCategoryRepository->find($classCategoryId1);
if (!$ClassCategory1) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category1']]);
$this->addErrors($message);
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category1']]);
$this->addErrors($message);
}
$ClassCategory2 = null;
if (isset($row[$headerByKey['class_category2']]) && StringUtil::isNotBlank($row[$headerByKey['class_category2']])) {
if ($pc->getClassCategory1() != null && $pc->getClassCategory2() == null) {
$message = trans('admin.common.csv_invalid_can_not', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
} else {
if (preg_match('/^\d+$/', $classCategoryId2)) {
$ClassCategory2 = $this->classCategoryRepository->find($classCategoryId2);
if (!$ClassCategory2) {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
} else {
if ($ClassCategory1 &&
($ClassCategory1->getClassName()->getId() == $ClassCategory2->getClassName()->getId())
) {
$message = trans('admin.common.csv_invalid_not_same', [
'%line%' => $line,
'%name1%' => $headerByKey['class_category1'],
'%name2%' => $headerByKey['class_category2'],
]);
$this->addErrors($message);
}
}
} else {
$message = trans('admin.common.csv_invalid_not_found', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
}
}
} else {
if ($pc->getClassCategory1() != null && $pc->getClassCategory2() != null) {
$message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['class_category2']]);
$this->addErrors($message);
}
}
$ProductClass = $this->createProductClass($row, $Product, $data, $headerByKey, $ClassCategory1, $ClassCategory2);
if ($this->BaseInfo->isOptionProductDeliveryFee()) {
if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
$deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
$errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
$ProductClass->setDeliveryFee($deliveryFee);
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
$this->addErrors($message);
}
}
}
// 商品別税率機能が有効の場合に税率を更新
if ($this->BaseInfo->isOptionProductTaxRule()) {
if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) {
$taxRate = $row[$headerByKey['tax_rate']];
$errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0]));
if ($errors->count() === 0) {
$TaxRule = $this->taxRuleRepository->newTaxRule();
$TaxRule->setTaxRate($taxRate);
$TaxRule->setApplyDate(new \DateTime());
$TaxRule->setProduct($Product);
$TaxRule->setProductClass($ProductClass);
$ProductClass->setTaxRule($TaxRule);
} else {
$message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]);
$this->addErrors($message);
}
}
}
$Product->addProductClass($ProductClass);
}
}
}
if ($this->hasErrors()) {
return $this->renderWithError($form, $headers);
}
$this->entityManager->persist($Product);
}
$this->entityManager->flush();
$this->entityManager->getConnection()->commit();
// 画像ファイルの削除(commit後に削除させる)
foreach ($deleteImages as $images) {
/** @var ProductImage $image */
foreach ($images as $image) {
if ($this->productImageRepository->findOneBy(['file_name' => $image->getFileName()])) {
continue;
}
try {
$fs = new Filesystem();
$fs->remove($this->eccubeConfig['eccube_save_image_dir'].'/'.$image);
} catch (\Exception $e) {
// エラーが発生しても無視する
}
}
}
log_info('商品CSV登録完了');
if (!$this->isSplitCsv) {
$message = 'admin.common.csv_upload_complete';
$this->session->getFlashBag()->add('eccube.admin.success', $message);
}
$cacheUtil->clearDoctrineCache();
}
}
}
return $this->renderWithError($form, $headers);
}
/**
* 商品登録CSVヘッダー定義
*
* @return array
*/
protected function getProductCsvHeader()
{
return [
trans('admin.product.product_csv.product_id_col') => [
'id' => 'id',
'description' => 'admin.product.product_csv.product_id_description',
'required' => false,
],
trans('admin.product.product_csv.display_status_col') => [
'id' => 'status',
'description' => 'admin.product.product_csv.display_status_description',
'required' => true,
],
trans('admin.product.product_csv.product_name_col') => [
'id' => 'name',
'description' => 'admin.product.product_csv.product_name_description',
'required' => true,
],
trans('admin.product.product_csv.shop_memo_col') => [
'id' => 'note',
'description' => 'admin.product.product_csv.shop_memo_description',
'required' => false,
],
trans('admin.product.product_csv.description_list_col') => [
'id' => 'description_list',
'description' => 'admin.product.product_csv.description_list_description',
'required' => false,
],
trans('admin.product.product_csv.description_detail_col') => [
'id' => 'description_detail',
'description' => 'admin.product.product_csv.description_detail_description',
'required' => false,
],
trans('admin.product.product_csv.brand_col') => [
'id' => 'brand',
'description' => 'admin.product.product_csv.brand_description',
'required' => false,
],
trans('admin.product.product_csv.number_col') => [
'id' => 'number',
'description' => 'admin.product.product_csv.number_description',
'required' => false,
],
trans('admin.product.product_csv.size_col') => [
'id' => 'size',
'description' => 'admin.product.product_csv.size_description',
'required' => false,
],
trans('admin.product.product_csv.material_col') => [
'id' => 'material',
'description' => 'admin.product.product_csv.material_description',
'required' => false,
],
trans('admin.product.product_csv.notification_email_col') => [
'id' => 'notification_email',
'description' => 'admin.product.product_csv.notification_email_description',
'required' => false,
],
trans('admin.product.product_csv.keyword_col') => [
'id' => 'search_word',
'description' => 'admin.product.product_csv.keyword_description',
'required' => false,
],
trans('admin.product.product_csv.free_area_col') => [
'id' => 'free_area',
'description' => 'admin.product.product_csv.free_area_description',
'required' => false,
],
trans('admin.product.product_csv.delete_flag_col') => [
'id' => 'product_del_flg',
'description' => 'admin.product.product_csv.delete_flag_description',
'required' => false,
],
trans('admin.product.product_csv.product_image_col') => [
'id' => 'product_image',
'description' => 'admin.product.product_csv.product_image_description',
'required' => false,
],
trans('admin.product.product_csv.category_col') => [
'id' => 'product_category',
'description' => 'admin.product.product_csv.category_description',
'required' => false,
],
trans('admin.product.product_csv.tag_col') => [
'id' => 'product_tag',
'description' => 'admin.product.product_csv.tag_description',
'required' => false,
],
trans('admin.product.product_csv.sale_type_col') => [
'id' => 'sale_type',
'description' => 'admin.product.product_csv.sale_type_description',
'required' => true,
],
trans('admin.product.product_csv.class_category1_col') => [
'id' => 'class_category1',
'description' => 'admin.product.product_csv.class_category1_description',
'required' => false,
],
trans('admin.product.product_csv.class_category2_col') => [
'id' => 'class_category2',
'description' => 'admin.product.product_csv.class_category2_description',
'required' => false,
],
trans('admin.product.product_csv.delivery_duration_col') => [
'id' => 'delivery_date',
'description' => 'admin.product.product_csv.delivery_duration_description',
'required' => false,
],
trans('admin.product.product_csv.product_code_col') => [
'id' => 'product_code',
'description' => 'admin.product.product_csv.product_code_description',
'required' => false,
],
trans('admin.product.product_csv.stock_col') => [
'id' => 'stock',
'description' => 'admin.product.product_csv.stock_description',
'required' => false,
],
trans('admin.product.product_csv.stock_unlimited_col') => [
'id' => 'stock_unlimited',
'description' => 'admin.product.product_csv.stock_unlimited_description',
'required' => false,
],
trans('admin.product.product_csv.sale_limit_col') => [
'id' => 'sale_limit',
'description' => 'admin.product.product_csv.sale_limit_description',
'required' => false,
],
trans('admin.product.product_csv.normal_price_col') => [
'id' => 'price01',
'description' => 'admin.product.product_csv.normal_price_description',
'required' => false,
],
trans('admin.product.product_csv.sale_price_col') => [
'id' => 'price02',
'description' => 'admin.product.product_csv.sale_price_description',
'required' => true,
],
trans('admin.product.product_csv.delivery_fee_col') => [
'id' => 'delivery_fee',
'description' => 'admin.product.product_csv.delivery_fee_description',
'required' => false,
],
trans('admin.product.product_csv.tax_rate_col') => [
'id' => 'tax_rate',
'description' => 'admin.product.product_csv.tax_rate_description',
'required' => false,
],
trans('admin.product.product_csv.product_class_visible_flag_col') => [
'id' => 'product_class_visible_flg',
'description' => 'admin.product.product_csv.product_class_visible_flag_description',
'required' => false,
],
];
}
}