@@ 1078-1102 (lines=25) @@ | ||
1075 | $ProductClass->setCode(null); |
|
1076 | } |
|
1077 | ||
1078 | if (!isset($row[$headerByKey['stock_unlimited']]) |
|
1079 | || StringUtil::isBlank($row[$headerByKey['stock_unlimited']]) |
|
1080 | || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED |
|
1081 | ) { |
|
1082 | $ProductClass->setStockUnlimited(false); |
|
1083 | // 在庫数が設定されていなければエラー |
|
1084 | if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) { |
|
1085 | $stock = str_replace(',', '', $row[$headerByKey['stock']]); |
|
1086 | if (preg_match('/^\d+$/', $stock) && $stock >= 0) { |
|
1087 | $ProductClass->setStock($stock); |
|
1088 | } else { |
|
1089 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1090 | $this->addErrors($message); |
|
1091 | } |
|
1092 | } else { |
|
1093 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1094 | $this->addErrors($message); |
|
1095 | } |
|
1096 | } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) { |
|
1097 | $ProductClass->setStockUnlimited(true); |
|
1098 | $ProductClass->setStock(null); |
|
1099 | } else { |
|
1100 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]); |
|
1101 | $this->addErrors($message); |
|
1102 | } |
|
1103 | ||
1104 | if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) { |
|
1105 | $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]); |
|
@@ 1256-1280 (lines=25) @@ | ||
1253 | $ProductClass->setCode(null); |
|
1254 | } |
|
1255 | ||
1256 | if (!isset($row[$headerByKey['stock_unlimited']]) |
|
1257 | || StringUtil::isBlank($row[$headerByKey['stock_unlimited']]) |
|
1258 | || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED |
|
1259 | ) { |
|
1260 | $ProductClass->setStockUnlimited(false); |
|
1261 | // 在庫数が設定されていなければエラー |
|
1262 | if ($row[$headerByKey['stock']] == '') { |
|
1263 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1264 | $this->addErrors($message); |
|
1265 | } else { |
|
1266 | $stock = str_replace(',', '', $row[$headerByKey['stock']]); |
|
1267 | if (preg_match('/^\d+$/', $stock) && $stock >= 0) { |
|
1268 | $ProductClass->setStock($row[$headerByKey['stock']]); |
|
1269 | } else { |
|
1270 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1271 | $this->addErrors($message); |
|
1272 | } |
|
1273 | } |
|
1274 | } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) { |
|
1275 | $ProductClass->setStockUnlimited(true); |
|
1276 | $ProductClass->setStock(null); |
|
1277 | } else { |
|
1278 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]); |
|
1279 | $this->addErrors($message); |
|
1280 | } |
|
1281 | ||
1282 | if ($row[$headerByKey['sale_limit']] != '') { |
|
1283 | $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]); |