NEW filter on entity in import

This commit is contained in:
VESSILLER 2022-12-01 14:33:35 +01:00
parent 62231d5b2f
commit 483e9814f9
2 changed files with 24 additions and 0 deletions

View File

@ -870,6 +870,10 @@ class ImportCsv extends ModeleImports
$filters[] = $col.' = '.$data[$key];
}
}
if (!empty($tablewithentity_cache[$tablename])) {
$where[] = "entity = ".((int) $conf->entity);
$filters[] = "entity = ".((int) $conf->entity);
}
$sqlSelect .= " WHERE ".implode(' AND ', $where);
$resql = $this->db->query($sqlSelect);
@ -906,6 +910,10 @@ class ImportCsv extends ModeleImports
}
$sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid);
if (!empty($tablewithentity_cache[$tablename])) {
$sqlSelect .= " AND entity = ".((int) $conf->entity);
}
$resql = $this->db->query($sqlSelect);
if ($resql) {
$res = $this->db->fetch_object($resql);
@ -951,6 +959,10 @@ class ImportCsv extends ModeleImports
$sqlend = " WHERE " . implode(' AND ', $where);
}
if (!empty($tablewithentity_cache[$tablename])) {
$sqlend .= " AND entity = ".((int) $conf->entity);
}
$sql = $sqlstart.$sqlend;
// Run update request

View File

@ -916,6 +916,10 @@ class ImportXlsx extends ModeleImports
$filters[] = $col.' = '.$data[$key];
}
}
if (!empty($tablewithentity_cache[$tablename])) {
$where[] = "entity = ".((int) $conf->entity);
$filters[] = "entity = ".((int) $conf->entity);
}
$sqlSelect .= " WHERE " . implode(' AND ', $where);
$resql = $this->db->query($sqlSelect);
@ -953,6 +957,10 @@ class ImportXlsx extends ModeleImports
}
$sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid);
if (!empty($tablewithentity_cache[$tablename])) {
$sqlSelect .= " AND entity = ".((int) $conf->entity);
}
$resql = $this->db->query($sqlSelect);
if ($resql) {
$res = $this->db->fetch_object($resql);
@ -998,6 +1006,10 @@ class ImportXlsx extends ModeleImports
$sqlend = " WHERE " . implode(' AND ', $where);
}
if (!empty($tablewithentity_cache[$tablename])) {
$sqlend .= " AND entity = ".((int) $conf->entity);
}
$sql = $sqlstart . $sqlend;
// Run update request