/** * 商品画像の削除、登録 */ protected function createProductImage($row, Product $Product) { if ($row['商品画像'] != '') { // 画像の削除 $ProductImages = $Product->getProductImage(); foreach ($ProductImages as $ProductImage) { $Product->removeProductImage($ProductImage); $this->em->remove($ProductImage); } // 画像の登録 $images = explode(',', $row['商品画像']); $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); } } }