@@ 1138-1162 (lines=25) @@ | ||
1135 | $ProductClass->setCode(null); |
|
1136 | } |
|
1137 | ||
1138 | if (!isset($row[$headerByKey['stock_unlimited']]) |
|
1139 | || StringUtil::isBlank($row[$headerByKey['stock_unlimited']]) |
|
1140 | || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED |
|
1141 | ) { |
|
1142 | $ProductClass->setStockUnlimited(false); |
|
1143 | // 在庫数が設定されていなければエラー |
|
1144 | if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) { |
|
1145 | $stock = str_replace(',', '', $row[$headerByKey['stock']]); |
|
1146 | if (preg_match('/^\d+$/', $stock) && $stock >= 0) { |
|
1147 | $ProductClass->setStock($stock); |
|
1148 | } else { |
|
1149 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1150 | $this->addErrors($message); |
|
1151 | } |
|
1152 | } else { |
|
1153 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1154 | $this->addErrors($message); |
|
1155 | } |
|
1156 | } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) { |
|
1157 | $ProductClass->setStockUnlimited(true); |
|
1158 | $ProductClass->setStock(null); |
|
1159 | } else { |
|
1160 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]); |
|
1161 | $this->addErrors($message); |
|
1162 | } |
|
1163 | ||
1164 | if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) { |
|
1165 | $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]); |
|
@@ 1316-1340 (lines=25) @@ | ||
1313 | $ProductClass->setCode(null); |
|
1314 | } |
|
1315 | ||
1316 | if (!isset($row[$headerByKey['stock_unlimited']]) |
|
1317 | || StringUtil::isBlank($row[$headerByKey['stock_unlimited']]) |
|
1318 | || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED |
|
1319 | ) { |
|
1320 | $ProductClass->setStockUnlimited(false); |
|
1321 | // 在庫数が設定されていなければエラー |
|
1322 | if ($row[$headerByKey['stock']] == '') { |
|
1323 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1324 | $this->addErrors($message); |
|
1325 | } else { |
|
1326 | $stock = str_replace(',', '', $row[$headerByKey['stock']]); |
|
1327 | if (preg_match('/^\d+$/', $stock) && $stock >= 0) { |
|
1328 | $ProductClass->setStock($row[$headerByKey['stock']]); |
|
1329 | } else { |
|
1330 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]); |
|
1331 | $this->addErrors($message); |
|
1332 | } |
|
1333 | } |
|
1334 | } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) { |
|
1335 | $ProductClass->setStockUnlimited(true); |
|
1336 | $ProductClass->setStock(null); |
|
1337 | } else { |
|
1338 | $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]); |
|
1339 | $this->addErrors($message); |
|
1340 | } |
|
1341 | ||
1342 | if (isset($row[$headerByKey['sale_limit']]) && $row[$headerByKey['sale_limit']] != '') { |
|
1343 | $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]); |