updating importing items 2

This commit is contained in:
Flatlogic Bot 2026-02-21 10:46:00 +00:00
parent a4b81a5393
commit 20fbd07aef

View File

@ -1185,10 +1185,17 @@ function getPromotionalPrice($item) {
$message = "Error: It looks like you uploaded an Excel (.xlsx) file. Please save it as CSV (UTF-8) and try again.";
} else {
$handle = fopen($tmpPath, "r");
fgetcsv($handle); // Skip header
$firstLine = fgets($handle);
rewind($handle);
$sep = ",";
if (strpos($firstLine, ";") !== false && strpos($firstLine, ",") === false) $sep = ";";
elseif (strpos($firstLine, "\t") !== false) $sep = "\t";
fgetcsv($handle, 0, $sep); // Skip header
$count = 0; $errors = 0;
while (($data = fgetcsv($handle)) !== FALSE) {
if (empty($data[1]) && empty($data[2])) continue;
while (($data = fgetcsv($handle, 0, $sep)) !== FALSE) {
if (empty($data[0]) && empty($data[1]) && empty($data[2])) continue;
try {
foreach ($data as &$val) {
if ($val === null) continue;
@ -1203,7 +1210,7 @@ function getPromotionalPrice($item) {
sale_price=VALUES(sale_price), purchase_price=VALUES(purchase_price)")
->execute([$data[0] ?? '', $data[1] ?? '', $data[2] ?? '', (float)($data[3] ?? 0), (float)($data[4] ?? 0)]);
$count++;
} catch (Exception $e) {
} catch (Throwable $e) {
$errors++;
}
}