diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index df33a299beb..41317a44cb9 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -1126,7 +1126,6 @@ public function export($filters = null) $tpObj = new \Centreon_Object_Timeperiod(); $macroObj = new \Centreon_Object_Host_Macro_Custom(); $instanceRel = new \Centreon_Object_Relation_Instance_Host(); - $parentShip = array(); if ($this->register) { $instElements = $instanceRel->getMergedParameters( @@ -1141,6 +1140,12 @@ public function export($filters = null) ); } + /* Init parentship */ + $parentShip = array(); + if ($this->register == 1) { + $parentShip = $this->getHostListByParent($elements); + } + foreach ($elements as $element) { $addStr = $this->action . $this->delim . "ADD"; foreach ($this->insertParams as $param) { @@ -1194,9 +1199,6 @@ public function export($filters = null) } // Set parentship - if ($this->register == 1) { - $parentShip = $this->getHostListByParent($elements); - } if (isset($parentShip[$element[$this->object->getPrimaryKey()]])) { foreach ($parentShip[$element[$this->object->getPrimaryKey()]] as $parentId) { echo $this->action . $this->delim