public function add(Produit $produit, $qty = 1) { //Soit j'ai un tableau vide soit un tableau plein d'id produit if ($this->session->get('panier')) { $allProducts = $this->session->get('panier'); } else { $allProducts = []; } //TRaitement sur la quantité if (array_key_exists($produit->getId(), $allProducts)) { // $allProducts[$product->getId()]; représente la quantité du produit $allProducts[$produit->getId()] = $allProducts[$produit->getId()] + $qty; //$qty = $allProducts[$product->getId()] + $qty } else { $allProducts[$produit->getId()] = $qty; } $this->session->set('panier', $allProducts); }