public function match($ref, $max_accepted = 5)
 {
     if (strlen($ref) == 0) {
         return 'KO';
     }
     $product = new Produit();
     $q = "SELECT p.id, p.ref, pd.titre, p.prix, p.prix2, p.promo, p.tva, p.rubrique\n                FROM {$product->table} p\n                    LEFT JOIN " . Produitdesc::TABLE . " pd\n                        ON p.id=pd.produit AND pd.lang='" . ActionsLang::instance()->get_id_langue_courante() . "'\n                WHERE\n                    p.ref LIKE '{$ref}%'\n                ";
     $r = $product->query($q);
     if ($product->num_rows($r) == 0) {
         return 'KO';
     }
     if ($product->num_rows($r) > $max_accepted) {
         return 'TOO_MUCH:' . $product->num_rows($r);
     }
     $retour = array();
     while ($r && ($a = $product->fetch_object($r))) {
         $retour[] = array("ref" => $a->ref, "titre" => $a->titre, "prix" => $a->prix, "prix2" => $a->prix2, "promo" => $a->promo, "tva" => $a->tva, "rubrique" => $a->rubrique, "stock" => $this->getVariants($a->id));
     }
     return json_encode($retour);
 }