Skip to content

Commit

Permalink
Merge pull request #2161 from k-yamamura/bugfix-importproductimage
Browse files Browse the repository at this point in the history
商品CSVアップロード時に商品画像に空文字が設定されていれば登録対象外とするように修正
  • Loading branch information
ryo-endo committed Mar 3, 2017
2 parents a6c6b9f + a75b31c commit a12dfb6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
19 changes: 11 additions & 8 deletions src/Eccube/Controller/Admin/Product/CsvImportController.php
Expand Up @@ -683,14 +683,17 @@ protected function createProductImage($row, Product $Product)
$rank = 1;
foreach ($images as $image) {

$ProductImage = new ProductImage();
$ProductImage->setFileName(Str::trimAll($image));
$ProductImage->setProduct($Product);
$ProductImage->setRank($rank);

$Product->addProductImage($ProductImage);
$rank++;
$this->em->persist($ProductImage);
$fileName = Str::trimAll($image);
if (!empty($fileName)) {
$ProductImage = new ProductImage();
$ProductImage->setFileName($fileName);
$ProductImage->setProduct($Product);
$ProductImage->setRank($rank);

$Product->addProductImage($ProductImage);
$rank++;
$this->em->persist($ProductImage);
}
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/Eccube/Controller/Admin/Product/ProductController.php
Expand Up @@ -416,8 +416,10 @@ public function edit(Application $app, Request $request, $id = null)
$app['orm.em']->persist($Product);

// 削除
$fs = new Filesystem();
$fs->remove($app['config']['image_save_realdir'] . '/' . $delete_image);
if (!empty($delete_image)) {
$fs = new Filesystem();
$fs->remove($app['config']['image_save_realdir'].'/'.$delete_image);
}
}
$app['orm.em']->persist($Product);
$app['orm.em']->flush();
Expand Down Expand Up @@ -576,8 +578,10 @@ public function delete(Application $app, Request $request, $id = null)
// 画像ファイルの削除(commit後に削除させる)
foreach ($deleteImages as $deleteImage) {
try {
$fs = new Filesystem();
$fs->remove($app['config']['image_save_realdir'] . '/' . $deleteImage);
if (!empty($deleteImage)) {
$fs = new Filesystem();
$fs->remove($app['config']['image_save_realdir'].'/'.$deleteImage);
}
} catch (\Exception $e) {
// エラーが発生しても無視する
}
Expand Down

0 comments on commit a12dfb6

Please sign in to comment.