diff --git a/classes/Customer.php b/classes/Customer.php index 6bdf2adaa..1b745e19f 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -143,6 +143,9 @@ class CustomerCore extends ObjectModel 'deleted' => array(), 'passwd' => array('setter' => 'setWsPasswd'), ), + 'associations' => array( + 'groups' => array('resource' => 'group'), + ) ); /** @@ -747,4 +750,22 @@ class CustomerCore extends ObjectModel return $total_paid - $total_rest; } + + public function getWsGroups() + { + return Db::getInstance()->ExecuteS(' + SELECT cg.`id_group` as id + FROM '._DB_PREFIX_.'customer_group cg + WHERE cg.`id_customer` = '.(int)$this->id); + } + + public function setWsGroups($result) + { + $groups = array(); + foreach ($result as $row) + $groups[] = $row['id']; + $this->cleanGroups(); + $this->addGroups($groups); + return true; + } } \ No newline at end of file