Make CommonObject::cloneCategories() generic (#36758)
It was working only for products Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
b957f768cb
commit
d6abd9305f
1 changed files with 6 additions and 3 deletions
|
|
@ -11529,9 +11529,12 @@ abstract class CommonObject
|
|||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$categorystatic = new Categorie($this->db);
|
||||
|
||||
$sql = "INSERT INTO ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type])." (fk_categorie, fk_product)";
|
||||
$sql .= " SELECT fk_categorie, $toId FROM ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
|
||||
$sql .= " WHERE fk_product = ".((int) $fromId);
|
||||
$tablename = $this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
|
||||
$fkname = 'fk_' . (empty($categorystatic->MAP_CAT_FK[$type]) ? $type : $categorystatic->MAP_CAT_FK[$type]);
|
||||
|
||||
$sql = "INSERT INTO ".$tablename." (fk_categorie, ".$fkname.")";
|
||||
$sql .= " SELECT fk_categorie, $toId FROM ".$tablename;
|
||||
$sql .= " WHERE ".$fkname." = ".((int) $fromId);
|
||||
|
||||
if (!$this->db->query($sql)) {
|
||||
$this->error = $this->db->lasterror();
|
||||
|
|
|
|||
Loading…
Reference in a new issue